$ mysqlbinlog mysql_binlog.000042 | head -10<br># The proper term is pseudo_replica_mode, but we use this compatibility alias<br># to make the statement usable on server versions 8.0.24 and older.<br>/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;<br>/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;<br>DELIMITER /*!*/;<br># at 4<br>#230504 11:53:30 server id 1 end_log_pos 126 Start: binlog v 4, server v 8.0.31 created 230504 11:53:30<br>BINLOG '<br>OixTZA8BAAAAegAAAH4AAAAAAAQAOC4wLjMxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<br>AAAAAAAAAAAAAAAAAAAAAAAAEwANAAgAAAAABAAEAAAAYgAEGggAAAAICAgCAAAACgoKKioAEjQA<br>
<p>A STOP_EVENT has not payload or post-header</p>
<p>ROTATE_EVENT</p>
<p>The rotate event is added to the binlog as last event to tell the reader what binlog to request next.<br>
</p>
复制代码
如下所示:
$ mysqlbinlog mysql_binlog.000042 | tail -10<br># at 533<br>#230504 12:13:35 server id 3 end_log_pos 560 Xid = 50948183<br>COMMIT/*!*/;<br># at 560<br>#230504 12:14:03 server id 1 end_log_pos 606 Rotate to mysql_binlog.000043 pos: 4<br>SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;<br>DELIMITER ;<br># End of log file<br>/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;<br>/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;<br>
复制代码
$ mysqlbinlog mysql_binlog.000042 |grep Rotate<br>#230504 12:14:03 server id 1 end_log_pos 606 Rotate to mysql_binlog.000043 pos: 4<br>$ mysqlbinlog mysql_binlog.000042 |grep Rotate | awk -F "server id" '{print $1}'<br>#230504 12:14:03<br>
复制代码
如果MySQL关闭后,对应的MySQL二进制日志的格式如下所示:
$ mysqlbinlog mysql_binlog.000045 | tail -10<br># at 126<br>#230504 17:02:23 server id 10 end_log_pos 157 CRC32 0x2d378ba5 Previous-GTIDs<br># [empty]<br># at 157<br>#230504 17:08:11 server id 10 end_log_pos 180 CRC32 0xb6b08f2c Stop<br>SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;<br>DELIMITER ;<br># End of log file<br>/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;<br>/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;<br>