官方github
https://github.com/liuhr/my2sql
1、安装
本想用源码安装,但一直报错,后来直接下载的二进制文件
wget https://raw.githubusercontent.com/liuhr/my2sql/master/releases/centOS_release_7.x/my2sql chmod +x my2sql ./my2sql
2、使用
语法和 binlog2sql 类似,不过有一些binlog2sql上的bug,在这个软件中没有。
比如timestamp(3)问题:
https://github.com/danfengcao/binlog2sql/issues/90
分析在线binlog,正向解析SQL
./my2sql -user root -password c123456 -host 127.0.0.1 -port 3357 -mode repl -work-type 2sql -start-file mysql-bin.000038 -start-datetime "2020-07-16 10:20:00" -output-dir ./tmpdir
分析在线binlog,生成回滚SQL
./my2sql -user root -password c123456 -host 127.0.0.1 -port 3357 -mode repl -work-type rollback -start-file mysql-bin.000038 -start-datetime "2020-07-16 10:20:00" -output-dir ./tmpdir
正向解析的SQL
root@ip-172-31-30-45:~/czg/tmpdir# cat forward.38.sql UPDATE `ceshi`.`t1` SET `sj`='2022-01-17 10:18:18.188' WHERE (`c1`='a' AND `c2`='b' AND `sj`='2022-01-17 09:41:22.451'); #解析的逆向SQL root@ip-172-31-30-45:~/czg/tmpdir# cat rollback.38.sql UPDATE `ceshi`.`t1` SET `sj`='2022-01-17 09:41:22.451' WHERE (`c1`='a' AND `c2`='b' AND `sj`='2022-01-17 10:18:18.188');
分析已经离线binlog,生成回滚SQL
./my2sql -user root -password c123456 -host 127.0.0.1 -port 3357 -mode file -work-type 2sql -local-binlog-file /usr/local/mysql57/data/mysql-bin.000038 -start-file /usr/local/mysql57/data/mysql-bin.000038 -start-datetime "2020-07-16 10:20:00" -output-dir ./tmpdir