mysql备份 公有云_mysql 备份 还原

比如我有个discuz的论坛网站,数据库名为discuz

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| discuz             |

| mysql              |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> use discuz;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

我发了个帖子,刚开始是可以正常浏览了,如果我删除了post表,会报如下错误:

Discuz! Database Error

(1146) Table 'discuz.forum_post' doesn't exist

mysql> show tables like "pre_%_post";

+-------------------------------+

| Tables_in_discuz (pre_%_post) |

+-------------------------------+

| pre_forum_debatepost          |

| pre_forum_filter_post         |

| pre_forum_post                |

| pre_security_evilpost         |

+-------------------------------+

4 rows in set (0.00 sec)

mysql> drop table pre_forum_post;//也可以直接drop table discuz.pre_forum_post;

Query OK, 0 rows affected (0.00 sec)

假如我在删除之前用mysqldump命令进行了备份,那么如果我误删除了数据,还是可以恢复回去的。

# mysqldump -uroot -p discuz > discuz.sql;//备份库

# mysql -uroot -p discuz <  discuz.sql;//恢复库

# mysqldump -uroot -p discuz pre_forum_post > pre_forum_post.sql;//备份表

# mysql -uroot -p discuz < pre_forum_post.sql;//恢复表,前半截跟恢复库的命令一样,后半部分选择备份的表sql就行

# mysqldump -uroot -p --default-character-set=gbk discuz pre_forum_post > pre_forum_post_gbk.sql;//指定字符集备份表

# mysql -uroot -p --default-character-set=gbk discuz < pre_forum_post_gbk.sql;//指定字符集恢复表,前半截跟恢复库的命令一样,后半部分选择备份的表sql就行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值