How to back up and restore a MySQL database with log-bin Enabled

Source: Internet
Author: User

MySQL databaseOfBinary logNot only for Replicate \ audit, but also for backup and restoration like other RDBMS systems. Next, we will introduce how to back up and restore the MySQL database with log-bin enabled.

The procedure is as follows:

(Optional): backs up binary log files.

Step 1: Start the server mysqld: Make sure some options are used

 
 
  1. # Cancel binary startup
  2.  
  3. # Log-bin
  4.  
  5. # Allow salve I/o thread to read its own server-id binary log records
  6.  
  7. Replicate-same-server-id
  8.  
  9. # The slave thread is not automatically started. You can leave it unspecified for the sake of security.
  10.  
  11. Skip-slave-start
  12.  
  13. # Define the basename of relay-log
  14.  
  15. Relay-log = "original log-bin (binary log) basename"

Step 2: Configure slave thread information change master

 
 
  1. Change master
  2.  
  3. Relay_log_file = 'start binary log file ',
  4.  
  5. Relay_log_pos = position of the starting binary log file,
  6.  
  7. Master_host = 'a false unavailable host or ip address'

The "master_host" in this statement is only required by the syntax and does not actually connect to it.

Step 3: Start the slave thread and restore it.

 
 
  1. start slave; 

Step 4: After restoration, start mysql in normal mode. Remember: Clear the salve files in the data directory!

Remember, clear the slave-related files in the data directory!

In this way, the restoration is successful. Here is an introduction to the backup and restoration of the MySQL database with log-bin enabled. I hope you will have some benefits!

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.