mysql log bin参数_mysqlbinlog常用参数

首先,给出我的MySQL版本

SELECT VERSION();

5.7.25-log

mysqlbinlog

--database

--base64-output=DECODE-ROWS #如果截取出来的日志是为了SOURCE执行,不要添加这个参数

--verbose

--set-charset=utf8

--skip-gtids

--include-gtids='bec1f53c-61b9-11e9-8871-000c29d144c9:200-2302' #需要再次执行的GTID

--exclude-gtids='bec1f53c-61b9-11e9-8871-000c29d144c9:220' #需要过滤掉的GTID

--result-file=/var/log/mysql/dump.sql

重要参数说明

--skip-gtids

这里先给出官方文档中的说法

Do not display any GTIDs in the output.

This is needed when writing to a dump file from

one or more binary logs containing GTIDs,

as shown in this example:

shell> mysqlbinlog --skip-gtids binlog.000001 > /tmp/dump.sql

shell> mysqlbinlog --skip-gtids binlog.000002 >> /tmp/dump.sql

shell> mysql -u root -p -e "source /tmp/dump.sql"

The use of this option is otherwise not normally recommended in production.

也就是说,除了上述用法,不建议在生产环境中使用这个参数。这个参数的作用可能是规避GTID的幂等性。经过试验,发现,如果没有加这个参数,截取出来的SQL二进制日志即使被SOURCE,也不会产生效果。另外,即使在sql_log_bin=1时,如果没有加上这个参数,由于幂等性,二进制日志并不会真正执行,所以,并不会产生新的二进制日志记录。

--base64-output=DECODE-ROWS

如果加上这个参数,截取出来的日志虽然可以SOURCE成功,但是不会执行SQL。

那么,给出结论,如果是为了查看截取出来的日志,加上这个参数和--verbose,如果是为了执行SQL,不要加这个参数。

遗留问题

--idempotent

Tell the MySQL Server to use idempotent mode while processing updates;

this causes suppression of any duplicate-key or key-not-found errors

that the server encounters in the current session while processing updates.

This option may prove useful whenever it is desirable or necessary to replay one or more binary logs to a MySQL Server which may not contain all of the data to which the logs refer.

The scope of effect for this option includes the current mysqlbinlog client and session only.

怎么理解和使用?

加上--database就可以按照库来筛选,如何以表为精度进行筛选?

参考文档

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值