mysql - 在不锁定表的情况下运行 MySQLDump

标签 mysql

我想将一个实时生产数据库复制到我的本地开发数据库中。有没有办法在不锁定生产数据库的情况下做到这一点?

我目前正在使用:

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/

相关文章:

mysql - 在 MySQL 列中搜索相似词

mysql - 使用 mysql 数据库部署 bcb6 应用程序的最佳方法?

mysql - Azure "MySQL server has gone away"仅一分钟

mysql - mysql 触发问题

php - 数组php和数据库mysql保存数据

mysql - 高级更新 - 通过从另一表获取数据来更新一个表中的列

javascript - 用于一次浏览数组一个值而无需刷新页面的按钮

php - MD5 在 SQL 数据库和 PHP 脚本中的作用不同

mysql范围查询性能

mysql - 如何选择一个查询中的列不在另一查询的列之间的记录?