1、备份mysql数据库中的数据库mysql

语法:mysqldump -uroot -proot mysql>mysql.sql(定义的数据库备份文件)

命令 用户名 用户密码 备份数据库


备份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、有路径的文件导出具体做法

D:\Documents and Settings\Administrator>mysqldump -uroot -proot mysql>f:/mysql1.sql

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 Duplicates: 0 Warnings: 0

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

更多相关文章

  1. python数据存储系列教程——python中mysql数据库操作:连接、增删
  2. MongoDB备份恢复与导入导出
  3. mysql数据库的主从同步过程详述
  4. 直接的文件备份和用sqlserver的备份有什么区别
  5. 工作日记(连接SQL Sever 2005服务器数据库)
  6. docker应用-6(mysql+mycat 搭建数据库集群)
  7. mysql数据库基本操作指南
  8. 项目连接MySQL数据库,提示异常
  9. MySQL数据库SQL语法

随机推荐

  1. Android中真正的Player
  2. Android(安卓)Studio编译使用了Maven的工
  3. 【学习Android遇到的错误】Unable to res
  4. Android中如何使用自定义对话框
  5. 【android】对canvas的translate(),save()
  6. android OOM的那些事
  7. Android设置上下边框或者左右边框
  8. AS中一个报错解决:LoggedErrorException:
  9. Android: How to download the latest zi
  10. Android 源码启动虚拟机经验