MySQL的日志基础知识及基本操作学习教程

2019-01-04 19:38:27于丽
***************************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)