-- 查看某个时间段的二进制日志, 并且输出到指定的文件
mysqlbinlog --no-defaults --start-datetime="2018-12-12 13:00:00" --stop-datetime="2018-12-12 14:40:00" MySQL-bin.000085 -vv --base64-output=decode-rows | more>> target.txt
-- 将 @1,@2 等一系列看不懂的符号转换为 SQL 语句
cat target.txt | sed -n '/###/p' | sed 's/### //g;s/\/\*.*/,/g;s/DELETE FROM/INSERT INTO/g;' | sed -r 's/(@4.*),/\1;/g' | sed 's/@[0-9]*\=//g'> test.sql
来源: http://www.bubuko.com/infodetail-3113305.html