binlog_rows_query_log_events row模式下记录sql语句

mysql 5.7后通过设置binlog_rows_query_log_events为on,可以在binlog_format=row中记录执行的SQL语句。

mysql> use mytest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> update t1 set name='tt' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0


#160418 14:39:23 server id 11  end_log_pos 662 CRC32 0x94bcfba8         Query   thread_id=112   exec_time=0     error_code=0
SET TIMESTAMP=1460961563/*!*/;
BEGIN
/*!*/;
# at 662
#160418 14:39:23 server id 11  end_log_pos 712 CRC32 0x0559e4ae         Table_map: `mytest`.`t1` mapped to number 112
# at 712
#160418 14:39:23 server id 11  end_log_pos 764 CRC32 0x7fafe939         Update_rows: table id 112 flags: STMT_END_F


BINLOG '
G4EUVxMLAAAAMgAAAMgCAAAAAHAAAAAAAAEABm15dGVzdAACdDEAAgMPAkAAA67kWQU=
G4EUVx8LAAAANAAAAPwCAAAAAHAAAAAAAAEAAgAC///8AgAAAAJubvwCAAAAAnR0Oemvfw==
'/*!*/;
### UPDATE `mytest`.`t1`
### WHERE
###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
###   @2='nn' /* VARSTRING(64) meta=64 nullable=1 is_null=0 */
### SET
###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
###   @2='tt' /* VARSTRING(64) meta=64 nullable=1 is_null=0 */
# at 764
#160418 14:39:23 server id 11  end_log_pos 795 CRC32 0x82e2d934         Xid = 1103
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;



mysql> set global binlog_rows_query_log_events=on;

mysql> update t1 set name='bb' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

BEGIN
/*!*/;
# at 934
#160418 14:46:59 server id 11  end_log_pos 992 CRC32 0x930e3483         Rows_query
# update t1 set name='bb' where id=2
# at 992
#160418 14:46:59 server id 11  end_log_pos 1042 CRC32 0x5b228624        Table_map: `mytest`.`t1` mapped to number 112
# at 1042
#160418 14:46:59 server id 11  end_log_pos 1094 CRC32 0x873d8144        Update_rows: table id 112 flags: STMT_END_F


BINLOG '
44IUVx0LAAAAOgAAAOADAACAACJ1cGRhdGUgdDEgc2V0IG5hbWU9J2JiJyB3aGVyZSBpZD0ygzQO
kw==
44IUVxMLAAAAMgAAABIEAAAAAHAAAAAAAAEABm15dGVzdAACdDEAAgMPAkAAAySGIls=
44IUVx8LAAAANAAAAEYEAAAAAHAAAAAAAAEAAgAC///8AgAAAAJ0dPwCAAAAAmJiRIE9hw==
'/*!*/;
### UPDATE `mytest`.`t1`
### WHERE
###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
###   @2='tt' /* VARSTRING(64) meta=64 nullable=1 is_null=0 */
### SET
###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
###   @2='bb' /* VARSTRING(64) meta=64 nullable=1 is_null=0 */
# at 1094
#160418 14:46:59 server id 11  end_log_pos 1125 CRC32 0xc28c3292        Xid = 1116
COMMIT/*!*/;

Query OK, 0 rows affected (0.00 sec)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26390465/viewspace-2083346/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26390465/viewspace-2083346/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值