binlog_rows_query_log_events 参数
随笔
mysql
设置这个参数=1,可以在binlog
日志中看到语句的原始sql
但是网上很多没说清楚,开了之后也看不到,因为在使用mysqlbinlog
查看时,需要加上-vv
参数才行,如下
mysqlbinlog -vv mysql-bin.00000x
如果你还想看到binlog日志中那些乱码所代表的的含义可以加上另一个参数
mysqlbinlog --base64-output=decode-rows -vv mysql-bin.00000x
图片演示
下方左边红框里的显示内容显示的具体程度可以由binlog_row_image参数控制,官方文档也有介绍
binlog_rows_query_log_events 的官方文档原话如下
This system variable affects row-based logging only. When enabled, it causes the server to write informational log events such as row query log events into its binary log. This information can be used for debugging and related purposes, such as obtaining the original query issued on the source when it cannot be reconstructed from the row updates.
These informational events are normally ignored by MySQL programs reading the binary log and so cause no issues when replicating or restoring from backup. To view them, increase the verbosity level by using mysqlbinlog’s --verbose option twice, either as -vv or --verbose --verbose.