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.