I'm new to MySQL and I'm figuring out the best way to perform an on-line hot logical backup using mysqldump
. This page suggests this command line:
mysqldump --single-transaction --flush-logs --master-data=2
--all-databases > backup_sunday_1_PM.sql
but... if you read the documentation carefully you find that:
While a
--single-transaction
dump is in process, to ensure a valid dump file (correct table contents and binary log position), no other connection should use the following statements:ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE
. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause theSELECT
performed bymysqldump
to retrieve the table contents to obtain incorrect contents or fail.
So, is there any way to prevent this possible dump corruption scenario? I.e. a commands that could block those statements temporarily.
PS: MySQL bug entry on this subject http://bugs.mysql.com/bug.php?id=27850