innodb引擎的数据库,在dump时加--single-transaction参数用来保证数据完整一致。
实际工作原理是设定本次会话的隔离级别为:REPEATABLE READ,来确保本次dump时,不会看到其他会话提交的数据。
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a