Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19755505
  • 博文数量: 679
  • 博客积分: 10495
  • 博客等级: 上将
  • 技术积分: 9308
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-18 10:51
文章分类

全部博文(679)

文章存档

2012年(5)

2011年(38)

2010年(86)

2009年(145)

2008年(170)

2007年(165)

2006年(89)

分类: Mysql/postgreSQL

2007-04-11 11:31:49

使用mysql客户端 §1.2 添加mysql用户账号

 

[root@Meil ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2 to server version: 5.0.27-max-log

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql> GRANT ALL ON cookbook.* TO 'cbuser'@'localhost' IDENTIFIED BY 'cbpass';

Query OK, 0 rows affected (0.12 sec)

 

退出的方法有quit,exit, Ctrl-D

mysql> quit

Bye

[root@Meil ~]# mysql -u cbuser

ERROR 1045 (28000): Access denied for user 'cbuser'@'localhost' (using password: NO)

 

注意要添加-p

[root@Meil ~]# mysql -u cbuser -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4 to server version: 5.0.27-max-log

 

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 

mysql>

 

§1.3 创建数据库和示例表

mysql> USE cookbook;

mysql> CREATE TABLE limbs (thing VARCHAR(20), legs INT, arms INT);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('human',2,2);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('insect',6,0);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('squid',0,10);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('octopus',0,8);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('fish',0,0);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('centipede',100,0);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('table',4,0);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('armchair',4,2);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('phonograph',0,1);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('tripod',3,0);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('Peg Leg Pete',1,2);

mysql> INSERT INTO limbs (thing,legs,arms) VALUES('space alien',NULL,NULL);

 

mysql> SELECT * FROM limbs;

+--------------+------+------+

| thing        | legs | arms |

+--------------+------+------+

| human        |    2 |    2 |

| insect       |    6 |    0 |

| squid        |    0 |   10 |

| octopus      |    0 |    8 |

| fish         |    0 |    0 |

| centipede    |  100 |    0 |

| table        |    4 |    0 |

| armchair     |    4 |    2 |

| phonograph   |    0 |    1 |

| tripod       |    3 |    0 |

| Peg Leg Pete |    1 |    2 |

| space alien  | NULL | NULL |

+--------------+------+------+

12 rows in set (0.00 sec)

阅读(2027) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~