Get the App
SLTechnology News&Howtos  ›  Database  › 

How to keep data consistency during mysqldump backup

Shulou Source: shulou.com Published: 2022-06-01 07:22:23 10月02日 Update

Mysqldump has different internal implementations for different types of storage engines. It is mainly aimed at two types of storage engines: storage engines that support transactions (such as InnoDB) and storage engines that do not support transactions (such as MyISAM). Let's take a look at the implementation of these two storage engines:

1. For engines that support transactions, such as InnoDB, add-single-transaction to the parameters when backing up to ensure data consistency

-- single-transaction actually does the following two operations:

1)。 Set the transaction isolation level of the session to repeatable read at the beginning

2)。 Then start a transaction (execute begin), and end the transaction when the backup ends (execute commit)

With these two operations, the data read by the session during the backup is the data (at the same point) when the backup was started. It can be understood that with the addition of this parameter to the innodb engine, the data to be backed up has been set at the beginning of the backup, and the committed transactions during the backup process will not be seen and will not be backed up.

Tags: Backup transaction engine storage data time support two parameters types procedures consistency consistency difference actual actually at the level guaranteed isolated Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker vpn MySQL Linux