mysqldump with WHERE id IN (SELECT …) yields table “was not locked” error

后端 未结 2 1634
我寻月下人不归
我寻月下人不归 2021-02-07 01:03

I have 2 databases, with ~100,000 rows missing from the table field_collection_item from db1, which I\'d like to repair by exporting from db2

相关标签:
2条回答
  • 2021-02-07 01:28

    If your tables are MyISAM, the safest, easiest way to handle this is to pass the flag --lock-all-tables. If your tables are InnoDB then --single-transaction is better.

    0 讨论(0)
  • 2021-02-07 01:28

    If you don't need a consistency guarantee, you can disable locking without single transaction by adding:

    --lock-tables=false

    I use this to do the same thing you're after (dumping subsets of the data) and on replication slaves that I can stop (making it consistent anyway).

    An advantage over --single-transaction is that you can use/mix non-MVCC-engine tables.

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