skip-lock-tables and mysqldump

后端 未结 1 1276
梦如初夏
梦如初夏 2021-02-07 04:10

Daily we run mysql dumps on about 50 individual databases, package them up and then store them offsite. Some of these databases are rather large and contain myisam tables (which

相关标签:
1条回答
  • 2021-02-07 05:07

    --skip-lock-tables parameter instructs the mysqldump utility not to issue a LOCK TABLES command before obtaining the dump which will acquire a READ lock on every table. All tables in the database should be locked, for improved consistency in case of a backup procedure. Even with skip-lock-tables, while a table is dumped, will not receive any INSERTs or UPDATEs whatsoever, as it will be locked due the SELECT required to obtain all records from the table. It looks like this

    SELECT SQL_NO_CACHE * FROM my_large_table
    

    and you can see it in the process list with the SHOW PROCESSLIST command. If you are using the MyISAM engine which is non-transactional, locking the tables will not guarantee referential integrity and data consistency in any case, I personally use the --skip-lock-tables parameter almost always. In InnoDB use the --single-transaction parameter for the expected effect. Hope this helps.

    0 讨论(0)
提交回复
热议问题