比如我有个Discuz的论坛网站,数据库名为discuzmysql> 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 namesYou 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就行