1. 程式人生 > >mysqldump 使用–single-transaction

mysqldump 使用–single-transaction

注意:innodb用 –single-transaction, myisam需要用 –lock-all-tables。

 mysqldump -uroot -p'R00t,uHagt.0511'  -R --single-transaction --master-data=2 --all-database >slave.sql


-R, --routines      Dump stored routines (functions and procedures).

-R 選項,匯出儲存過程

  --single-transaction 
                      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
                      valid dump file (correct table contents and binary log
                      position), no other connection should use the following
                      statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
                      TRUNCATE TABLE, as consistent snapshot is not isolated
                      from them. Option automatically turns off --lock-tables.


建立一個一致性的快照通過dump所有的表在一個單獨的transaction裡,只能用於儲存在支援多版本的(當前只支援InnoDB)儲存引擎;


dump不保證其他引擎的一致性。當--single-transaction dump執行時,為了確保正確的dump file(正確的表的內容和binary log的位置),


沒有其他連結使用下面的語句:ALTER TABLE, DROP TABLE, RENAME TABLE,TRUNCATE TABLE,因為一致的快照不是和它們脫離的


選項自動關閉 --lock-tables