1、备份mysql数据库中的数据库mysql
备份test数据库中的单张表:
C:\Documents and Settings\Administrator>mysqldump -uroot -p test t2>d:/t2bak.txt
Enter password:
备份test数据中的t2,t1两张表:
C:\Documents and Settings\Administrator>mysqldump -uroot -p test t2 t1>d:/t2bak.txt
Enter password:
注意:在备份一个数据库中的两张表的时候用空格隔开,不能用"," 号,并且要求是英文状态下的符号。
2、有路径的文件导出具体做法
3、上面的目录可以是你想将数据库备份放置的位置(f:/mysql1.sql)
4、如果不带数据库的备份路径时数据库存储的位置是当前目录下
1、删除表t2:
mysql> drop table t2;
Query OK, 0 rows affected (0.02 sec)
2、已经不存在了:
mysql> select * from t2
ERROR 1146 (42S02): Table 'test.t2' doesn't exist
3、还原:
C:\Documents and Settings\Administrator>mysql test <d:/t2bak.txt
OR
mysql> source d:/t2bak.txt
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.03 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 5 rows affected (0.00 sec)
Records: 5
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.05 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
4、查询已恢复:
mysql> select * from t2
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 6 |
+---+
5 rows in set (0.00 sec)
本文出自 “守候者” 博客,请务必保留此出处http://shouhouzhe.blog.51cto.com/2351955/1376942