MySQL导出导入命令的用例
2008-10-20 11:11:35 来源:WEB开发网 闂傚倸鍊搁崐鎼佸磹閹间礁纾归柟闂寸绾惧綊鏌熼梻瀵割槮缁惧墽鎳撻—鍐偓锝庝簻椤掋垺銇勯幇顖毿撻柟渚垮妼椤粓宕卞Δ鈧獮濠勭磽閸屾艾鈧懓顫濋妸鈺佺疅缂佸顑欓崥瀣煕椤愵偅绶氱紓鍐╂礋濮婂宕掑▎鎴М濠电姭鍋撻梺顒€绉甸幆鐐哄箹濞n剙濡肩紒鎰殜閺屸€愁吋鎼粹€茬敖婵炴垶鎸哥粔鐢稿Φ閸曨垰鍐€妞ゆ劦婢€濞岊亪姊虹紒妯诲蔼闁稿海鏁诲濠氭晲婢跺﹤宓嗛梺缁樺姈缁佹挳宕戦幘璇叉嵍妞ゆ挻绋戞禍鐐叏濡厧浜鹃悗姘炬嫹

随着数据的增多,数据的备份显得日益重要,下面是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
更多精彩
赞助商链接