[mysql@localhost ~]$ mysqlbinlog /mysqldata/mysql/binlog.000001 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #191115 15:39:01 server id 1 end_log_pos 123 CRC32 0x2d9d7b4f Start: binlog v 4, server v 5.7.26-log created 191115 15:39:01 at startup # Warning: this binlog is either in use or was not closed properly. ROLLBACK/*!*/; BINLOG ' FVbOXQ8BAAAAdwAAAHsAAAABAAQANS43LjI2LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAVVs5dEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA AU97nS0=
# at 736 #191115 15:51:45 server id 1 end_log_pos 801 CRC32 0xc2c892b8 Anonymous_GTID last_committed=2 sequence_number=3 rbr_only=no SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 801 #191115 15:51:45 server id 1 end_log_pos 882 CRC32 0x51a9cd5c Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804305/*!*/; BEGIN /*!*/; # at 882 # at 914 #191115 15:51:45 server id 1 end_log_pos 914 CRC32 0x40a98fae Intvar SET INSERT_ID=2/*!*/; #191115 15:51:45 server id 1 end_log_pos 1082 CRC32 0x3396c40d Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804305/*!*/; insert into person(last_name,first_name,birth,death) values('yan','huang','1990-08-25',null) /*!*/; # at 1082 #191115 15:51:45 server id 1 end_log_pos 1164 CRC32 0xf6f6efad Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804305/*!*/; COMMIT /*!*/; # at 1164 #191115 15:51:53 server id 1 end_log_pos 1229 CRC32 0x55b50dbe Anonymous_GTID last_committed=3 sequence_number=4 rbr_only=no SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 1229 #191115 15:51:53 server id 1 end_log_pos 1310 CRC32 0xd0f6a335 Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804313/*!*/; BEGIN /*!*/; # at 1310 # at 1342 #191115 15:51:53 server id 1 end_log_pos 1342 CRC32 0xfad94baf Intvar SET INSERT_ID=3/*!*/; #191115 15:51:53 server id 1 end_log_pos 1508 CRC32 0x26c5b3bb Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804313/*!*/; insert into person(last_name,first_name,birth,death) values('yali','ye','1994-12-23',null) /*!*/; # at 1508 #191115 15:51:53 server id 1 end_log_pos 1590 CRC32 0xbb6a2b4c Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804313/*!*/; 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*/; 上面输出了binlog.000001二进制日志文件中所包含的内容。对于基于语句的日志,事件信息包括SQL语句,执行语句的服务器ID,语句被执行的时间戳,执行时间等。对于基于行记录的日志,事件信息指示行的改变而不是SQL语句。
# at 486 #191115 15:51:38 server id 1 end_log_pos 486 CRC32 0xb746cd30 Intvar SET INSERT_ID=1/*!*/; #191115 15:51:38 server id 1 end_log_pos 654 CRC32 0x0e926042 Query thread_id=2 exec_time=0 error_code=0 SET TIMESTAMP=1573804298/*!*/; 第一行,at后面的数字指示事件在二进制日志文件中的偏移量或开始位置。