(4.8)mysql备份还原——binlog查看工具之mysqlbinlog及show binlog的使用
关键词:show binlog,mysql binlog查看,二进制文件查看,binlog查看工具,binlog查看方法
0、使用show master status;
使用它可以直接查看binlog日志信息;
总结:
指定文件:show binlog events in 'binlog.000001';
指定位置:show binlog events in 'binlog.000001' from 1009;
指定行数:show binlog events in 'binlog.000001' limit 5; show binlog events in 'binlog.000001' from 1009 limit 5;
指定偏移量:show binlog events in 'binlog.000001' limit 5,2;
1、show binlog events;
【1.1】使用in参数
(1)如果不指定文件,则默认查看第一个文件
(2)指定文件:show binlog events in 'binlog.000001';
测试 -- 建表 create table test2(id int primary key not null auto_increment, tablename varchar(200),UUID varchar(50), timepoint datetime not null default current_timestamp, currentversion timestamp not null default current_timestamp on update current_timestamp )engine=innodb ; -- 插入数据 insert into test2(tablename,UUID) select 'test2',uuid(); -- 更新数据 update test2 set tablename='test2_update' where id = 1; -- 提交 commit;
show binlog events in 'binlog.000001';
【1.2】from pos,指定从哪个pos起始点开始查起;
如上图,我们直接从1009开始看。
show binlog events in 'binlog.000001' from 1009;
【1.3】limit row_count,查看多少条,或者from 701 limit 2(在701 pos位置后,查看2条)
如【1.1】中图,我们直接查看5条;
show binlog events in 'binlog.000001' limit 5;
如【1.1】中图,我们从701开始,查看2条;
show binlog events in 'binlog.000001' from 701 limit 2;
【1.4】limit offset,偏移量,从某个位置,查看多少条。
show binlog events in 'binlog.000001' limit 5,2;
show binlog events in 'binlog.000001' from 621 limit 2,2; 那么这就会在621之后偏移2行,再获取2行。也就是说,621行之后的第3行开始获取,拿2行。