MySQL -- When mysqldump, mysql -- mysqldump

Source: Internet
Author: User

MySQL -- When mysqldump, mysql -- mysqldump

In the previous MySQL -- When mysqldump -- single-transaction encounters alter table test, we found that in MySQL 5.6, If you modify the table during mysqldump, an error may occur in mysqldump, this conclusion is inconsistent with the execution of colleagues. Therefore, we will test it in MySQL 5.5.

Test environment:

MySQL 5.5.14

Table tb1001 is available in the database testdb01. The current table contains two pieces of data:

##=================================================== ================================ ##

The returned result is an empty set and no error is reported.

This explains how my colleagues operate: During mysqldump, the table structure modification operation is not blocked, and the mysqldump operation is also "normal".

Because SELECT /*! 40001 SQL _NO_CACHE */* FROM 'tb1001' the operation does not return errors or data. The mysqldump process treats tb1001 as an empty table, then, export the following tables until all the tables are exported, and then return the successful execution status. However, the exported backup has missing data of tb1001. If this backup is used to restore data, it will inevitably lead to "data loss ".

Solution:

Before modifying a table in MySQL 5.5, check whether the current server is performing the mysqldump operation to avoid parallel execution of the two.

 

If you modify a table that has been exported by mysqldump, the modification will be blocked until mysqldump ends. This is consistent with MySQL 5.6.

##=================================================== ========================================================== ============== ##

Summary:

For MySQL 5.5, mysqldump and table modification are executed simultaneously:

If the table modification operation starts in the period before "mysqldump is enabled but the table data has not been exported", the table modification operation is successful, and mysqldump does not fail, however, data in the modified table cannot be exported normally;

If the modification operation starts in the period before "mysqldum has exported and modified table data, but mysqldump has not been completed", the modification operation is blocked and mysqldum can be successfully completed, after the mysqldump operation is complete, the table modification operation can be executed normally.

 

For MySQL 5.5, avoid mysqldump and table modification at the same time to avoid backup loss and data inconsistency!

##=================================================== ========================================================== ============== ##

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.