随笔 - 116  文章 - 5  评论 - 1  阅读 - 14万

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   JennyYu  阅读(157)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示