文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>[mysql cook book mysql 菜谱] 第一章: 使用mysq..

[mysql cook book mysql 菜谱] 第一章: 使用mysq..

时间:2007-04-11  来源:oychw

§1,使用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)

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载