MySQL日志详细解析(10)

查看二进制日志信息的命令:
SHOW BINLOG EVENTS[IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
mysql> showbinlog events\G        #查看所有的二进制信息
***************************87. row ***************************
  Log_name: mysql-bin.000001
        Pos: 13580
 Event_type: Query
  Server_id: 1
End_log_pos: 13688
      Info: use `hellodb`; /*!40000 ALTERTABLE `toc` DISABLE KEYS */
***************************88. row ***************************
  Log_name: mysql-bin.000001
        Pos: 13688
 Event_type: Query
  Server_id: 1
End_log_pos: 13795
      Info: use `hellodb`; /*!40000 ALTERTABLE `toc` ENABLE KEYS */
***************************89. row ***************************
  Log_name: mysql-bin.000001
        Pos: 13795
 Event_type: Stop
  Server_id: 1
End_log_pos: 13814
      Info:
89 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011';    #查看指定日志的二进制信息
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
| Log_name        | Pos | Event_type  | Server_id | End_log_pos | Info                                        |
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011|  4 | Format_desc |        1 |        107 | Server ver: 5.5.33-log, Binlogver: 4        |
| mysql-bin.000011 |107 | Query      |        1 |        190 | create database yong                        |
| mysql-bin.000011 |190 | Query      |        1 |        293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query      |        1 |        357 | BEGIN                                        |
| mysql-bin.000011 |357 | Query      |        1 |        452 | insert into yong.tb1values(1,'tom')        |
| mysql-bin.000011 |452 | Xid        |        1 |        479 | COMMIT /* xid=103 */                        |
+------------------+-----+-------------+-----------+-------------+----------------------------------------------+
6 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011' from 190; #从指定的事件位置开始
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| Log_name        | Pos | Event_type | Server_id |End_log_pos | Info                                        |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011 |190 | Query      |        1 |        293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query      |        1 |        357 | BEGIN                                        |
| mysql-bin.000011 |357 | Query      |        1 |        452 | insert into yong.tb1values(1,'tom')        |
| mysql-bin.000011 |452 | Xid        |        1 |        479 | COMMIT /* xid=103 */                        |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
4 rows in set (0.00sec)
mysql> showbinlog events in 'mysql-bin.000011' from 190 limit 3;  #指定偏移量(不是语句,是事件)
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| Log_name        | Pos | Event_type | Server_id |End_log_pos | Info                                        |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
| mysql-bin.000011 |190 | Query      |        1 |        293 | create table yong.tb1 (idint,name char(20)) |
| mysql-bin.000011 |293 | Query      |        1 |        357 | BEGIN                                        |
| mysql-bin.000011 |357 | Query      |        1 |        452 | insert into yong.tb1values(1,'tom')        |
+------------------+-----+------------+-----------+-------------+----------------------------------------------+
3 rows in set (0.00sec)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2664cb88d7126d3636e3a9c8cb6894c4.html