我想把现场制作数据库复制到我当地的开发数据库中.有没有办法在不锁定生产数据库的情况下执行此操作?
我目前正在使用:
mysqldump -u root --password=xxx -h xxx my_db1 | mysql -u root --password=xxx -h localhost my_db1
但它会在运行时锁定每张桌子.
我想把现场制作数据库复制到我当地的开发数据库中.有没有办法在不锁定生产数据库的情况下执行此操作?
我目前正在使用:
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 DB美元:
mysqldump --single-transaction=TRUE -u username -p DB