前言
从MySQL5.6开始binlog的同步模式便有了binlog_row_image,那这个参数能给binlog带来什么变化呢?我们一起看下。
CREATE TABLE `a` (
`id` bigint(20) DEFAULT NULL,
`a` varchar(128) DEFAULT NULL,
`b` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
mysql> show global variables like 'binlog_row_image';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| binlog_row_image | FULL |
+------------------+-------+
mysql> select * from a;
+------+--------------------+--------+
| id | a | b |
+------+--------------------+--------+
| 1 | full | bbbbbb |
| 2 | buduibudui | 22222 |
+------+--------------------+--------+
2 rows in set (0.00 sec)
### UPDATE `test`.`a`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=1 is_null=0 */
### @2='full2minimal' /* VARSTRING(384) meta=384 nullable=1 is_null=0 */
### @3='bbbbbb' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */
### @4=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### SET
### @1=1 /* LONGINT meta=0 nullable=1 is_null=0 */
### @2='full2minimal2' /* VARSTRING(384) meta=384 nullable=1 is_null=0 */
### @3='bbbbbb' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */
### @4=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### UPDATE `test`.`a`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=1 is_null=0 */
### @2='full2minimal2' /* VARSTRING(384) meta=384 nullable=1 is_null=0 */
### @3='bbbbbb' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */
### @4=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### SET
### @2='full2minimal' /* VARSTRING(384) meta=384 nullable=1 is_null=0 */
注
这个参数修改后只对新建的连接有效,老连接还是沿用老模式
参考
https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html
https://dev.mysql.com/doc/internals/en/binlog-row-image.html