Mysql binlog 查看方法(2)

2021-10-19 11:44:33 浏览数 (1)

SHOW BINLOG EVENTS

代码语言:javascript复制
mysql> use testxxx;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
 ------------------- 
| Tables_in_testxxx |
 ------------------- 
| test              |
 ------------------- 
1 row in set (0.00 sec)

mysql> select * from test;
 ------ ---------- 
| id   | name     |
 ------ ---------- 
|    1 | hello1   |
|    2 | hello2   |
|    3 | hello3   |
|    4 | hello4   |
|    5 | hello5   |
...
...
|   97 | hello97  |
|   98 | hello98  |
|   99 | hello99  |
|  100 | hello100 |
 ------ ---------- 
99 rows in set (0.01 sec)

mysql> SHOW BINLOG EVENTS;
 ------------------ ----- ------------- ----------- ------------- -------------------------------------------- 
| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                       |
 ------------------ ----- ------------- ----------- ------------- -------------------------------------------- 
| mysql-bin.000001 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.27-76.0-log, Binlog ver: 4 |
 ------------------ ----- ------------- ----------- ------------- -------------------------------------------- 
1 row in set (0.00 sec)

mysql> delete from test where id=100;
Query OK, 1 row affected (0.10 sec)

mysql> SHOW BINLOG EVENTS;
 ------------------ ----- ------------- ----------- ------------- ---------------------------------------------- 
| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                         |
 ------------------ ----- ------------- ----------- ------------- ---------------------------------------------- 
| mysql-bin.000001 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.27-76.0-log, Binlog ver: 4   |
| mysql-bin.000001 | 120 | Query       |         1 |         205 | BEGIN                                        |
| mysql-bin.000001 | 205 | Query       |         1 |         314 | use `testxxx`; delete from test where id=100 |
| mysql-bin.000001 | 314 | Xid         |         1 |         345 | COMMIT /* xid=15 */                          |
 ------------------ ----- ------------- ----------- ------------- ---------------------------------------------- 
4 rows in set (0.03 sec)

mysql> 

再更新一条数据

代码语言:javascript复制
mysql> update test set name = 'change99' where id=99;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SHOW BINLOG EVENTS;
 ------------------ ------ ------------- ----------- ------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
| Log_name         | Pos  | Event_type  | Server_id | End_log_pos | Info                                                                                                                                                                                                                                                                                                                                   |
 ------------------ ------ ------------- ----------- ------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
| mysql-bin.000001 |    4 | Format_desc |         1 |         120 | Server ver: 5.6.27-76.0-log, Binlog ver: 4                                                                                                                                                                                                                                                                                             |
| mysql-bin.000001 |  120 | Query       |         1 |         205 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 |  205 | Query       |         1 |         314 | use `testxxx`; delete from test where id=100                                                                                                                                                                                                                                                                                           |
| mysql-bin.000001 |  314 | Xid         |         1 |         345 | COMMIT /* xid=15 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 |  345 | Query       |         1 |         428 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 |  428 | Intvar      |         1 |         460 | INSERT_ID=1584                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 |  460 | Query       |         1 |         773 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612140001', '20160612140001', 1, 'CROND[5870]:')                                                                              |
| mysql-bin.000001 |  773 | Xid         |         1 |         804 | COMMIT /* xid=17 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 |  804 | Query       |         1 |         887 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 |  887 | Intvar      |         1 |         919 | INSERT_ID=1585                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 |  919 | Query       |         1 |        1237 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (run-parts /etc/cron.hourly)', 9, 'h105', 6, '20160612140101', '20160612140101', 1, 'CROND[5877]:')                                                                         |
| mysql-bin.000001 | 1237 | Xid         |         1 |        1268 | COMMIT /* xid=18 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 1268 | Query       |         1 |        1351 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 1351 | Intvar      |         1 |        1383 | INSERT_ID=1586                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 1383 | Query       |         1 |        1701 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' starting 0anacron', 9, 'h105', 5, '20160612140101', '20160612140101', 1, 'run-parts(/etc/cron.hourly)[5877]:')                                                                         |
| mysql-bin.000001 | 1701 | Xid         |         1 |        1732 | COMMIT /* xid=19 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 1732 | Query       |         1 |        1815 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 1815 | Intvar      |         1 |        1847 | INSERT_ID=1587                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 1847 | Query       |         1 |        2165 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' finished 0anacron', 9, 'h105', 5, '20160612140101', '20160612140101', 1, 'run-parts(/etc/cron.hourly)[5886]:')                                                                         |
| mysql-bin.000001 | 2165 | Xid         |         1 |        2196 | COMMIT /* xid=20 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 2196 | Query       |         1 |        2279 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 2279 | Intvar      |         1 |        2311 | INSERT_ID=1588                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 2311 | Query       |         1 |        2624 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612141001', '20160612141001', 1, 'CROND[5902]:')                                                                              |
| mysql-bin.000001 | 2624 | Xid         |         1 |        2655 | COMMIT /* xid=21 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 2655 | Query       |         1 |        2738 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 2738 | Intvar      |         1 |        2770 | INSERT_ID=1589                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 2770 | Query       |         1 |        3083 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612142001', '20160612142001', 1, 'CROND[5922]:')                                                                              |
| mysql-bin.000001 | 3083 | Xid         |         1 |        3114 | COMMIT /* xid=22 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 3114 | Query       |         1 |        3197 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 3197 | Intvar      |         1 |        3229 | INSERT_ID=1590                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 3229 | Query       |         1 |        3542 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612143001', '20160612143001', 1, 'CROND[5942]:')                                                                              |
| mysql-bin.000001 | 3542 | Xid         |         1 |        3573 | COMMIT /* xid=23 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 3573 | Query       |         1 |        3656 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 3656 | Intvar      |         1 |        3688 | INSERT_ID=1591                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 3688 | Query       |         1 |        4001 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612144001', '20160612144001', 1, 'CROND[5962]:')                                                                              |
| mysql-bin.000001 | 4001 | Xid         |         1 |        4032 | COMMIT /* xid=24 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 4032 | Query       |         1 |        4115 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 4115 | Intvar      |         1 |        4147 | INSERT_ID=1592                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 4147 | Query       |         1 |        4537 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' Address 192.168.100.1 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!', 10, 'h105', 6, '20160612144840', '20160612144840', 1, 'sshd[5979]:') |
| mysql-bin.000001 | 4537 | Xid         |         1 |        4568 | COMMIT /* xid=25 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 4568 | Query       |         1 |        4651 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 4651 | Intvar      |         1 |        4683 | INSERT_ID=1593                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 4683 | Query       |         1 |        5023 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' Accepted password for root from 192.168.100.1 port 51286 ssh2', 10, 'h105', 6, '20160612144840', '20160612144840', 1, 'sshd[5979]:')                                                   |
| mysql-bin.000001 | 5023 | Xid         |         1 |        5054 | COMMIT /* xid=26 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 5054 | Query       |         1 |        5137 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 5137 | Intvar      |         1 |        5169 | INSERT_ID=1594                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 5169 | Query       |         1 |        5511 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' pam_unix(sshd:session): session opened for user root by (uid=0)', 10, 'h105', 6, '20160612144840', '20160612144840', 1, 'sshd[5979]:')                                                 |
| mysql-bin.000001 | 5511 | Xid         |         1 |        5542 | COMMIT /* xid=27 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 5542 | Query       |         1 |        5625 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 5625 | Intvar      |         1 |        5657 | INSERT_ID=1595                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 5657 | Query       |         1 |        5970 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612145001', '20160612145001', 1, 'CROND[6008]:')                                                                              |
| mysql-bin.000001 | 5970 | Xid         |         1 |        6001 | COMMIT /* xid=28 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 6001 | Query       |         1 |        6084 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 6084 | Intvar      |         1 |        6116 | INSERT_ID=1596                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 6116 | Query       |         1 |        6429 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (/usr/lib64/sa/sa1 1 1)', 9, 'h105', 6, '20160612150001', '20160612150001', 1, 'CROND[6040]:')                                                                              |
| mysql-bin.000001 | 6429 | Xid         |         1 |        6460 | COMMIT /* xid=43 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 6460 | Query       |         1 |        6543 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 6543 | Intvar      |         1 |        6575 | INSERT_ID=1597                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 6575 | Query       |         1 |        6893 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' (root) CMD (run-parts /etc/cron.hourly)', 9, 'h105', 6, '20160612150101', '20160612150101', 1, 'CROND[6046]:')                                                                         |
| mysql-bin.000001 | 6893 | Xid         |         1 |        6924 | COMMIT /* xid=44 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 6924 | Query       |         1 |        7007 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 7007 | Intvar      |         1 |        7039 | INSERT_ID=1598                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 7039 | Query       |         1 |        7357 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' starting 0anacron', 9, 'h105', 5, '20160612150101', '20160612150101', 1, 'run-parts(/etc/cron.hourly)[6046]:')                                                                         |
| mysql-bin.000001 | 7357 | Xid         |         1 |        7388 | COMMIT /* xid=45 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 7388 | Query       |         1 |        7471 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 7471 | Intvar      |         1 |        7503 | INSERT_ID=1599                                                                                                                                                                                                                                                                                                                         |
| mysql-bin.000001 | 7503 | Query       |         1 |        7821 | use `Syslog`; insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (' finished 0anacron', 9, 'h105', 5, '20160612150101', '20160612150101', 1, 'run-parts(/etc/cron.hourly)[6055]:')                                                                         |
| mysql-bin.000001 | 7821 | Xid         |         1 |        7852 | COMMIT /* xid=46 */                                                                                                                                                                                                                                                                                                                    |
| mysql-bin.000001 | 7852 | Query       |         1 |        7937 | BEGIN                                                                                                                                                                                                                                                                                                                                  |
| mysql-bin.000001 | 7937 | Query       |         1 |        8062 | use `testxxx`; update test set name = 'change99' where id=99                                                                                                                                                                                                                                                                           |
| mysql-bin.000001 | 8062 | Xid         |         1 |        8093 | COMMIT /* xid=47 */                                                                                                                                                                                                                                                                                                                    |
 ------------------ ------ ------------- ----------- ------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
71 rows in set (0.01 sec)

mysql> select * from test where id =  99;
 ------ ---------- 
| id   | name     |
 ------ ---------- 
|   99 | change99 |
 ------ ---------- 

0 人点赞