#使用-v参数的情形,可以看到我们操作生成的SQL语句了,为insert into ..@1之类的形式,如果-vv则输出列的描述信息
#BINLOG部分依旧被显示出来
SHELL> mysqlbinlog -v /opt/data/APP01bin.000001|grep truncate -B20
/*!*/;
# at 310
#141218 16:28:05 server id 11 end_log_pos 358 CRC32 0xe0025004 Table_map: `test`.`t1` mapped to number 74
# at 358
#141218 16:28:05 server id 11 end_log_pos 402 CRC32 0x3452dcfe Write_rows: table id 74 flags: STMT_END_F
BINLOG '
FZCSVBMLAAAAMAAAAGYBAAAAAEoAAAAAAAEABHRlc3QAAnQxAAICDwI8AAMEUALg
FZCSVB4LAAAALAAAAJIBAAAAAEoAAAAAAAEAAgAC//wBAAVyb2Jpbv7cUjQ=
'/*!*/;
### INSERT INTO `test`.`t1`
### SET
### @1=1
### @2='robin'
# at 402
#141218 16:28:05 server id 11 end_log_pos 433 CRC32 0xbe26740a Xid = 30
COMMIT/*!*/;
# at 433
#141218 16:29:00 server id 11 end_log_pos 517 CRC32 0x89c52d6a Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1418891340/*!*/;
truncate table t1
#添加--base64-output=DECODE-ROWS选项来抑制BINLOG的显示,如下我们看不到了BINLOG部分
SHELL> mysqlbinlog --base64-output=DECODE-ROWS -v /opt/data/APP01bin.000001|grep truncate -B20
/*!*/;
# at 238
#141218 16:28:05 server id 11 end_log_pos 310 CRC32 0x60507739 Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1418891285/*!*/;
BEGIN
/*!*/;
# at 310
#141218 16:28:05 server id 11 end_log_pos 358 CRC32 0xe0025004 Table_map: `test`.`t1` mapped to number 74
# at 358
#141218 16:28:05 server id 11 end_log_pos 402 CRC32 0x3452dcfe Write_rows: table id 74 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=1
### @2='robin'
# at 402
#141218 16:28:05 server id 11 end_log_pos 433 CRC32 0xbe26740a Xid = 30
COMMIT/*!*/;
# at 433
#141218 16:29:00 server id 11 end_log_pos 517 CRC32 0x89c52d6a Query thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1418891340/*!*/;
truncate table t1
#此时使用mysqlbinlog做一个不完全恢复
SHELL> mysqlbinlog --database=test --start-position="238" --stop-position="433" /opt/data/APP01bin.000001 |mysql -uroot -p --database=test
Enter password:
#查看恢复后的结果
SHELL> mysql -uroot -p -e "select * from test.t1"
Enter password:
+------+-------+
| id | val |
+------+-------+
| 1 | robin |
+------+-------+
MySQL binlog三种格式介绍及分析