查看mysql二进制文件(binlog文件)

 

a、使用sql命令查看binlog文件

 

1、查看binlog文件列表

mysql> show binary logs;

 

 2、查看当前正在写入的binlog文件

mysql>show master status;

 

 3、查看指定binlog文件的内容

 mysql>show binlog events [in 'log_name'] [FROM pos] [limit [offset,] row_count]

 

b、使用mysqlbinlog查看binlog文件内容

 

1、输出指定binlog文件内容

  mysqlbinlog binlog文件

 

 2、输出指定position位置的binlog日志

mysqlbinlog --start-position="指定开始位置" --stop-position="指定结束位置" binlog文件

 

 3、输出指定position位置的binlog日志到指定文件中

mysqlbinlog --start-position="指定开始位置" --stop-position="指定结束位置" binlog文件 > 输出文件名

或者

mysqlbinlog --start-position="指定开始位置" --stop-position="指定结束位置" binlog文件 --result-file=输出文件名

 

4、输出指定position位置的binlog日志到压缩文件中

 mysqlbinlog --start-position="指定开始位置" --stop-position="指定结束位置" binlog文件|gzip > 压缩文件名

 

5、输出指定开始时间的binlog日志

mysqlbinlog --start-datetime="yyyy-MM-dd HH:mm:ss" binlog文件 

 

 

 

 

参考地址

查看binlog文件的2种方式 https://blog.csdn.net/u010433704/article/details/54962680

 

posted @ 2019-10-10 17:14  harara  阅读(7255)  评论(0编辑  收藏  举报