MySQL Backup restore

Source: Internet
Author: User

For example, I have a discuz forum website with a database named 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

Can turn off this feature to get a quicker startup with-a


Database changed

I sent a post, just at the beginning can be normal browsing, if I delete the Post table, will report the following error:

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;//can also drop table discuz.pre_forum_post directly;

Query OK, 0 rows Affected (0.00 sec)

If I had backed up with the mysqldump command before the deletion, I could have returned it if I had deleted the data by mistake.

# mysqldump-uroot-p discuz > discuz.sql;//Backup Library

# Mysql-uroot-p Discuz < discuz.sql;//Recovery Library


# mysqldump-uroot-p Discuz pre_forum_post > pre_forum_post.sql;//Backup table

# mysql-uroot-p Discuz < pre_forum_post.sql;//Restore the table, the first half of the same as the Restore library commands, the latter part selects the backed up table SQL on the line


# mysqldump-uroot-p--DEFAULT-CHARACTER-SET=GBK discuz pre_forum_post > pre_forum_post_gbk.sql;//specifying a Character Set backup table

# mysql-uroot-p--DEFAULT-CHARACTER-SET=GBK Discuz < pre_forum_post_gbk.sql;//Specify the character Set recovery table, the first half of the same as the Restore Library command, The second half selects the backed up table SQL on the line

MySQL Backup restore

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.