my2sql
简介
go版MySQL binlog解析工具,通过解析MySQL binlog ,可以生成原始SQL、回滚SQL、去除主键的INSERT SQL等,也可以生成DML统计信息。https://github.com/liuhr/my2sql
安装
编译
git clone https://github.com/liuhr/my2sql.git
cd my2sql/
go build .
也可以直接下载Linux版编译好的可执行文件
https://github.com/liuhr/my2sql/blob/master/releases/my2sql
应用案例
误删整张表数据,需要紧急回滚
mysql> #数据库
mysql> show create database testdb\G
*************************** 1. row ***************************
Database: testdb
Create Database: CREATE DATABASE `testdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 */
mysql> #表结构
mysql> show create table student\G
*************************** 1. row ***************************
Table: student
Create Table: CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`number` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`add_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加的时间',
`content` json DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_name` (`number`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1234 DEFAULT CHARSET=utf8
mysql> #数据
mysql> select * from student;
+------+--------+---------+---------------------+---------------------------------+
| id | number | name | add_time | content |
+------+--------+---------+---------------------+---------------------------------+
| 12 | 12 | che | 2020-07-06 19:39:17 | NULL |
| 1217 | 12 | hanraan | 2020-07-06 19:39:17 | NULL |
| 1218 | 12 | NULL | 2020-07-06 19:39:17 | NULL |
| 1219 | 12 | hanran | 2020-07-06 19:39:17 | NULL |
| 1221 | 13 | hanran | 2020-07-06 19:40:10 | NULL |
| 1222 | 14 | hanran | 2020-07-06 19:42:17 | NU