可以通过这种方式来查看下二进制日志中的内容,主要的过程,可以看到语句在日志中是怎么存放的,在slave机器上就是按照这个顺序去执行sql的。
show binlog events in 'mysql-bin.000007'\G
*************************** 1. row ***************************Log_name: mysql-bin.000007
Pos: 4
Event_type: Format_desc
Server_id: 1951013400
End_log_pos: 120
Info: Server ver: 5.6.21-log, Binlog ver: 4
*************************** 2. row ***************************
Log_name: mysql-bin.000007
Pos: 120
Event_type: Rotate
Server_id: 1951013400
End_log_pos: 167
Info: mysql-bin.000008;pos=4
2 rows in set (0.00 sec)
show binlog events in 'mysql-bin.000006'\G
*************************** 1. row ***************************
Log_name: mysql-bin.000006
Pos: 4
Event_type: Format_desc
Server_id: 1951013400
End_log_pos: 120
Info: Server ver: 5.6.21-log, Binlog ver: 4
*************************** 2. row ***************************
Log_name: mysql-bin.000006
Pos: 120
Event_type: Query
Server_id: 1951013400
End_log_pos: 192
Info: BEGIN
*************************** 3. row ***************************
Log_name: mysql-bin.000006
Pos: 192
Event_type: Table_map
Server_id: 1951013400
End_log_pos: 240
Info: table_id: 79 (test.t2)
*************************** 4. row ***************************
Log_name: mysql-bin.000006
Pos: 240
Event_type: Write_rows
Server_id: 1951013400
End_log_pos: 284
Info: table_id: 79 flags: STMT_END_F
*************************** 5. row ***************************
Log_name: mysql-bin.000006
Pos: 284
Event_type: Xid
Server_id: 1951013400
End_log_pos: 315
Info: COMMIT /* xid=119 */
*************************** 6. row ***************************
Log_name: mysql-bin.000006
Pos: 315
Event_type: Rotate
Server_id: 1951013400
End_log_pos: 362
Info: mysql-bin.000007;pos=4
6 rows in set (0.01 sec)
flush logs;---强制产生新的二进制文件
Query OK, 0 rows affected (0.06 sec)