我想将一个实时生产数据库复制到我的本地开发数据库中。有没有办法在不锁定生产数据库的情况下做到这一点?
我目前正在使用:
mysqldump -u root --password=xxx -h xxx my_db1 | mysql -u root --password=xxx -h localhost my_db1
但它会在运行时锁定每个表。
最佳答案
--lock-tables=false
选项是否有效?
根据man page ,如果你正在转储 InnoDB 表,你可以使用 --single-transaction
选项:
--lock-tables, -l
Lock all tables before dumping them. The tables are locked with READ
LOCAL to allow concurrent inserts in the case of MyISAM tables. For
transactional tables such as InnoDB and BDB, --single-transaction is
a much better option, because it does not need to lock the tables at
all.
对于 innodb 数据库:
mysqldump --single-transaction=TRUE -u username -p DB
关于mysql - 在不锁定表的情况下运行 MySQLDump,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/104612/