MySQL mysqlbinlog解析出的SQL语句被注释是怎么回事
一网友反馈使用mysqlbinlog解析出的二进制日志中的内容中,有些SQL语句有#注释的情况,这个是怎么回事呢?我们通过实验来了解一下具体细节情况,如下所示,实验环境为5.6.20-enterprise-commercial-advanced-log
# whereis mysqlbinlog
mysqlbinlog: /usr/bin/mysqlbinlog /usr/share/man/man1/mysqlbinlog.1.gz
我们先在参数文件my.cnf里面设置binlog_format=ROW ,然后重启一下MySQL服务
mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show master status;
+----------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+----------------------+----------+--------------+------------------+-------------------+
| DB-Server-bin.000005 | 512 | | | |
+----------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql>
mysql> drop table kkk;
Query OK, 0 rows affected (0.01 sec)
mysql> create table kkk (id int ,name varchar(32));
Query OK, 0 rows affected (0.02 sec)
mysql> insert into kkk
-> select 100, 'name' union all
-> select 200, 'kerry' union all
-> select 300, 'k3';
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql>