The restoration after the MySQL database is deleted.

Source: Internet
Author: User

The restoration after the MySQL database is deleted.

In the morning, I accidentally deleted a database I just created yesterday! Fortunately, the log feature is enabled in mysql.

The following describes how to restore a deleted database:

First, save the most recent binary log files as text files and export them. The command is as follows:

Mysqlbinlog F:/wamp/mysql-bin.000045> F:/test.txt

Second, open the saved txt file in the following format:

Here, at 1099 represents 1,099th commands (Let's note). query these commands to see where the command you want to reply is and then execute the command.

Finally, execute the reply Command, as shown below:

Mysqlbinlog -- start-position = "123" -- stop-position = "531" F:/wamp/mysql-bin.000045 F:/test.txt | mysql-uroot-p

In this way, you can complete the database reply !!!


How can I restore the deleted mysql database?

You cannot solve this problem because the data files must be changed at any time. Therefore, you can recover a large number of files with the same name. Make sure that the file is the latest one. If it is confirmed that the latest data file cannot be imported into the database, there is no way to restore it !!
Unless your data is important, Professional staff will fix your files!

In mysql, the default "mysql" database is deleted. What is the impact? How should I recover the data?

1. Find a single machine to install mysql of the same version or other machines with the same version installed (you can try it out for a different version ):
Copy the mysql/data/mysql directory to your mysql/data/directory.
2. Start the mysql service. If the mysql service can be started, in theory, only user, authorization, and other system information should be lost, without affecting your data usage;
If it cannot be started, check the error log and try to start it.
3. Back up the data and re-import all the databases (only the business-related databases you created later, not the mysql databases. Theoretically, this is acceptable, but it is only in a non-production environment.
4. Re-authorize the user.

Related Article

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.