mysqldump命令详解 --master-data参数的使用

本文解析了MySQL的mysqldump命令中两个关键参数:--master-data用于记录二进制日志位置和文件名,以及--max-allowed-packet控制CHANGEMASTER语句的格式。理解这些选项有助于更精确地进行数据库备份和迁移操作。
摘要由CSDN通过智能技术生成
--master-data[=#]   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 (in which case a global read lock is only
                      taken a short time at the beginning of the dump; don't
                      forget to read about --single-transaction below). In all
                      cases, any action on logs will happen at the exact moment
                      of the dump. Option automatically turns --lock-tables
                      off.
  --max-allowed-packet=#

If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded.
If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded.
If no option value is specified, the default value is 1.
如果选项赋值为2,那么CHANGE MASTER TO 语句会被写成一个SQL comment(注释),从而只提供信息;
如果选项赋值为1,那么语句不会被写成注释并且在dump被载入时生效。
如果没有指定,默认值为1。https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702

https://www.cndba.cn/hbhe0316/article/22702
[root@mysql57 data]# mysqldump -h127.0.0.1 -uroot -pwwwwww --single-transaction --set-gtid-purged=OFF  --databases testdb  --master-data=1   --triggers --events --routines> /tmp/testdb1_all_master.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702

[root@mysql57 data]# mysqldump -h127.0.0.1 -uroot -pwwwwww --single-transaction --set-gtid-purged=OFF  --databases test  --master-data=2   --triggers --events --routines> /tmp/test_all_master.sql

https://www.cndba.cn/hbhe0316/article/22702https://www.cndba.cn/hbhe0316/article/22702

版权声明:本文为博主原创文章,未经博主允许不得转载。

MYSQL

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值