MYSQL数据库的使用
//进入Mysql数据库服务器,C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.2-alpha-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
//列出所有的数据库
mysql> show databases
-> ;
+----------+
| Database |
+----------+
| mysql |
| sampledb |
| test |
+----------+
3 rows in set (0.02 sec)
//使用sampledb数据库
mysql> use sampledb;
Database changed
//列出sampledb数据库中所有的表
mysql> show tables;
+--------------------+
| Tables_in_sampledb |
+--------------------+
| customers |
| orders |
+--------------------+
2 rows in set (0.02 sec)
//启动MYSQL数据库服务
C:\Program Files\MySQL\MySQL Server 5.0\bin>net start mysql
MySQL 服务已经启动成功。
//执行D:\sampledb.sql中的SQL语句
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p <D:\sampledb.sql
Enter password: ******
//进入MYSQL数据库
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.2-alpha-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases
-> ;
+----------+
| Database |
+----------+
| mysql |
| sampledb |
+----------+
2 rows in set (0.02 sec)
mysql> show tables
-> ;
ERROR 1046 (3D000): No database selected
mysql> use sampledb
Database changed
mysql> show tables
-> ;
+--------------------+
| Tables_in_sampledb |
+--------------------+
| customers |
+--------------------+
1 row in set (0.03 sec)
mysql>
页:
[1]