MySQL导出导入命令的用例
2008-10-20 11:11:35 来源:WEB开发网随着数据的增多,数据的备份显得日益重要,下面是mysql常用的数据导入导出命令。
1.导出整个数据库
格式:mysqldump -u 用户名 -p 数据库名 > 导出的文件名
举例:
C:Documents and SettingsOwner>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 5 to server version: 5.0.7-beta-nt
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> use testdb
Database changed
mysql> select * from user;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | aaa | aaa | aaaa |
| 2 | bbb | bbbb | bbbb@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
mysql> select * from user1;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | cccc | cccc | cccc |
| 2 | cccc | cccc | cccc@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
在mysql的bin目录里面执行如下命令
C:MySQLMySQL Server 5.0bin>mysqldump -u root -p testdb > testdb.sql
更多精彩
赞助商链接