4

学习mysql数据库


我的测试机上没有设root密码,设置下(内网机器,出不了外网,所以也没去动)。
设置root密码的命令为

  1. set password for 'root'@'localhost'=password('你的密码');
  1. root@debian:~# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitorCommands end with ; or \g.
  4. Your MySQL connection id is 12
  5. Server version: 5.0.32-Debian_7etch6-log Debian etch distribution
  6.  
  7. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  8.  
  9. mysql> set password for 'root'@'localhost'=password('123456');
  10. Query OK, 0 rows affected (0.22 sec)


创建数据库 名字为man.

  1. mysql> create database man;
  2. Query OK, 1 row affected (0.07 sec)

使用man这个数据库.

  1. mysql> use man;
  2. Database changed

创建数据库的表

  1. mysql> create table man (
  2.     -> id int unique not null,
  3.     -> name varchar(40),
  4.     -> age varchar(50),
  5.     -> primary key(id)
  6.     -> );
  7. Query OK, 0 rows affected (0.00 sec)

增加表单内容

  1. mysql> INSERT INTO man VALUES(1,'Brian','28');    
  2. Query OK, 1 row affected (0.00 sec)
  3.  
  4. mysql> INSERT INTO man VALUES(2,'Billy','26');       
  5. Query OK, 1 row affected (0.00 sec)
  6.  
  7. mysql> INSERT INTO man VALUES(3,'Dimitri','26');      
  8. Query OK, 1 row affected (0.01 sec)
  9.  
  10.  
  11. mysql> INSERT INTO man VALUES(4,'ross','30');           
  12. Query OK, 1 row affected (0.00 sec)

定义出这么个表格,ID,姓名,年龄。

  1. mysql> select * from man;
  2. +----+---------+------+
  3. | id | name    | age  |
  4. +----+---------+------+
  5. 1 | Brian   | 28   |
  6. 2 | Billy   | 26   |
  7. 3 | Dimitri | 26   |
  8. 4 | ross    | 30   |
  9. +----+---------+------+
  10. 4 rows in set (0.00 sec)



mysql学习中…

我猜~这些文章你可能也感兴趣

总共有4个留言:

  1. longlan on 十二 11th, 2008 - 22:52

    看到内网就让我想起了公共安全专家局了。。。哎!


    回复:看来longlan也是专家..

  2. 十二星座 on 十二 11th, 2008 - 23:30

    呵呵,博主紧张了啊,貌似写错位了,创建和使用数据库那好像大意了吧~~~


    回复:改过来啦,谢谢提醒哦!

  3. 十二星座 on 十二 11th, 2008 - 23:53

    呵呵,我现在也正在学习php呢,正好也在贵地瞅瞅了,看书眼睛受不了~~


    回复:星座你抬举我了,我也是新手在学习的..一起进步~

  4. 诗意地栖息在大地上 on 十二 12th, 2008 - 08:48

    昨天在本地安装了一些wp,呵呵,用的是哪个集成包。


    回复:哦哦,集成的会方便些的~

给我留言:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word