[root@CentOS ~]# mysql -u root -p ← 用root登录到MySQL服务器 Enter password: ← 输入MySQL的root用户密码 Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 8 to server version: 4.1.20 Type 'help;' or '/h' for help. Type '/c' to clear the buffer. mysql> create database test; ← 建立一个测试用的数据库test Query OK, 1 row affected (0.00 sec) mysql> use test ← 连接到这个数据库 Database changed mysql> create table test(num int, name varchar(50)); ← 在数据库中建立一个表 Query OK, 0 rows affected (0.07 sec) mysql> insert into test values(1,'Hello,CentOS'); ← 插入一个值到这个表(这里以“Hello,CentOS”为例) Query OK, 1 row affected (0.02 sec) mysql> select * from test; ← 查看数据库中的内容 +------+-----------------+ | num | name | +------+-----------------+ |1 | Hello,Centos | ← 确认刚刚插入到表中的值的存在 +------+------------------+ 1 row in set (0.01 sec) mysql> exit ← 退出MySQL服务器 Bye |