• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
开到荼蘼
博客园    首页    新随笔    联系   管理    订阅  订阅
linux下mysql的备份和还原

1.备份:

[root@localhost ~]# mysqldump -u root -p test>/opt/test.sql
Enter password: 

使用mysqldump备份, 并将备份文件指向输出目录, 输入密码即可

2.还原:

先创建要还原的数据库

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
+--------------------+
2 rows in set (0.00 sec)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> exit
Bye

指向备份文件进行还原

[root@localhost ~]# mysql -u root -p test</opt/test.sql 
Enter password:

 

 

 

posted on 2013-12-10 10:05  开到荼蘼  阅读(370)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3