Mysql二进制查看工具mysqlbinlog学习 2019-11-13

一、使用步骤

以下通过windows系统进行说明,其他系统类似。

1、需要确认你的电脑中已经安装Mysql数据库,然后进入到其安装文件中对应的bin目录下,在本目录下你会发现mysqlbinlog.exe文件:

1.png

2、在本目录下按住shift键同时点击鼠标右键,进入到CMD命令行,这个时候就可以使用mysqlbinlog命令了。

3、具体示例如下:

2.png
  • 3.1将mysql二进制日志文件转换为txt文件
./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000416 > E:1.txt

本步骤已经将二进制文件转换为可阅读的文本文件,但是查看sql语句的时候发现已经base64转码了,无法直接查看,这个时候就需要用到另外一个参数--base64-output=DECODE-ROWS -v。加上此参数再执行相关命令,就可以查看相关的SQL信息了,具体请看3.2章节。

  • 3.2将文件转换为可以执行的SQL:--base64-output=DECODE-ROWS -v

./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000416 > E:helpme.txt --base64-output=DECODE-ROWS -v

3.png

4、总结

  • 4.1将mysql二进制日志文件转换为txt文件
./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000416 > E:1.txt
  • 4.2将文件转换为可以执行的SQL
./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000416 > E:helpme.txt --base64-output=DECODE-ROWS -v
4.png
./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000416 > E:1.txt

二、参考资料

https://www.jianshu.com/p/6432188bc3d9

https://github.com/danfengcao/binlog2sql

https://www.cnblogs.com/f-ck-need-u/p/9001061.html

https://blog.csdn.net/worldchinalee/article/details/79972053

https://macdownload.informer.com/hexminer/download/?cf22d92&p296dc=1

MySQL binlog基本用法

https://www.iteblog.com/mysql-binlog_basic_usage/

MySQL 的 binlog 文件解析

https://my.oschina.net/Rayn/blog/2221362

MySQL 通过 binlog 恢复数据

https://learnku.com/articles/20628

mysqlbinlog——日志恢复数据库文件

https://blog.csdn.net/martingpf/article/details/82733786

mysqlbinlog 查看binlog时报错unknown variable 'default-character-set=utf8'

https://www.cnblogs.com/cobbliu/p/4311926.html

MySQL binlog基本用法

https://www.iteblog.com/mysql-binlog_basic_usage/

mysqlbinlog——日志恢复数据库文件

https://blog.csdn.net/martingpf/article/details/82733786

https://www.cnblogs.com/f-ck-need-u/p/9001061.html

mysqlbinlog 查看binlog时报错unknown variable 'default-character-set=utf8'

https://blog.csdn.net/yabingshi_tech/article/details/51224534

https://blog.csdn.net/qq_35440040/article/details/78111050

./mysqlbinlog --no-defaults D:\xinhai\mariadb\data\mysql-bin.000482 > E:LOG20191017.txt --base64-output=DECODE-ROWS -v

你可能感兴趣的:(Mysql二进制查看工具mysqlbinlog学习 2019-11-13)