Home  >  Article  >  Database  >  How to restore mysql after deletion

How to restore mysql after deletion

下次还敢
下次还敢Original
2024-04-14 19:30:271020browse

Deleted MySQL data recovery method: stop the server (1), back up the data directory (2), log in as super user (3), execute the recovery command in sequence (4), restore the data directory backup (5) , start the server (6).

How to restore mysql after deletion

How to recover deleted MySQL data

Steps to recover deleted data

  1. Stop the MySQL server.
  2. Back up the MySQL data directory.
  3. Start the MySQL server, and log in as super user.
  4. Run the following command to restore data:
<code>mysql -u root -p
USE database_name;
PURGE BINARY LOGS BEFORE 'log_name';
STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=0;
RESET SLAVE;</code>

Where:

  • database_name is the deleted data database name.
  • log_name is the name of the binary log file that is logged before data is deleted.
  1. Restore the backup of the MySQL data directory.
  2. Start the MySQL server.

Note:

  • This recovery method can only be used if binary logging is enabled.
  • After recovery, all data created after deleting the data will be lost.
  • If this method cannot be used, you can also try to use third-party tools or contact the database administrator for help.

The above is the detailed content of How to restore mysql after deletion. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn