六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 65|回复: 0

MYSQL数据库的使用

[复制链接]

升级  63.33%

39

主题

39

主题

39

主题

秀才

Rank: 2

积分
145
 楼主| 发表于 2013-1-27 04:44:35 | 显示全部楼层 |阅读模式
//进入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>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表