mysqldump命令的选项参数

1. --single-transaction 

 创建一个一致性快照,在一个单一事务里导出所有表。目前只有支持多版本的innodb 引擎支持此选项,对其他引擎不保证一致性。
 在dump期间,其他连接不能有如下ddl操作: ALTER TABLE, DROP TABLE, RENAME TABLE,TRUNCATE TABLE, 因为一致性快照不会隔离这些命令.此选项会自动将关闭 --lock-tables

2.-l, --lock-tables

Lock all tables for read.(Defaults to on; use --skip-lock-tables to disable.)

3.-x, --lock-all-tables

Locks all tables across all databases.

This is achieved by taking a global read lock for the duration of the whole dump.

Automatically turns --single-transaction and --lock-tables off.

4.--master-data[=#] (1,2)

This causes the binary log position and filename to be appended to the output.

If equal to 1, will print it as a CHANGE MASTER command;

if equal to 2, that command will be prefixed with a comment symbol.This option will turn --lock-all-tables on, unless --single-transaction is specified too 

 this will still take a global read lock . it is only taken a short time at the beginning of the dump.

In all cases, any action on logs will happen at the exact moment of the dump. Option automatically turns --lock-tables off.

5.-F, --flush-logs

Flush logs file in server before starting dump.

Note that if you dump many databases at once (using the option --databases= or --all-databases), the logs will be flushed for each database dumped.

The exception is when using --lock-all-tables or --master-data: in this case the logs will be flushed only once, corresponding to the moment all tables are locked. So if you want your dump and the log flush to happen at the same exact moment you should use --lock-all-tables or --master-data with --flush-logs.

6.--set-gtid-purged[=name]

Add 'SET @@GLOBAL.GTID_PURGED' to the output.

可取值为: ON, COMMENTED, OFF and AUTO.
值为ON时,如果数据库没有启用gtid,将会报错。

If COMMENTED is used, 'SET @@GLOBAL.GTID_PURGED' is added as a comment.

If OFF is used, this option does nothing.

If AUTO is used and GTIDs are enabled on the server, 'SET @@GLOBAL.GTID_PURGED' is added to the output. If GTIDs are disabled, AUTO does
nothing. If no value is supplied then the default (AUTO) value will be considered.

 

posted on 2022-06-09 09:39  JennyYu  阅读(151)  评论(0编辑  收藏  举报