MySQL?????????ο?????????
?????danfengcao ???????[ 2016/12/23 15:20:05 ] ????????????? MySQL
?????????????????????????????????????????????£??????????????MySQL?????????ο??????????磬delete???????????????????????????????????????????????????????????????????????????????????????????????
?????????
???????????????????????????????binlog?????????????????????????????????????SQL??????????binlog??????????????????????????
????????binlog2sql????????
???????????????MySQL server??????binlog???????????2???:
????[mysqld]
????server-id = 1
????log_bin = /var/log/mysql/mysql-bin.log
????max_binlog_size = 1000M
????binlog-format = row
?????????п???binlog???????????????SQL??????????????????????????????????????MySQL??????????binlog??
?????????????????binlog2sql??binlog2sql???????????binlog??????????????????????????binlog?????????
????git clone https://github.com/danfengcao/binlog2sql.git
????pip install -r requirements.txt
????????????????????SQL???
???????????????test??tbl????????????????????????
????test??tbl?????????
????mysql> select * from tbl;
????+----+--------+---------------------+
????| id | name | addtime |
????+----+--------+---------------------+
????| 1 | С?? | 2016-12-10 00:04:33 |
????| 2 | С? | 2016-12-10 00:04:48 |
????| 3 | С?? | 2016-12-10 00:04:51 |
????| 4 | С?? | 2016-12-10 00:04:56 |
????+----+--------+---------------------+
????4 rows in set (0.00 sec)
????mysql> delete from tbl;
????Query OK?? 4 rows affected (0.00 sec)
????tbl??????
????mysql> select * from tbl;
????Empty set (0.00 sec)
?????????????裺
????1?????mysql????????binlog???
????mysql> show master logs;
????+------------------+-----------+
????| Log_name | File_size |
????+------------------+-----------+
????| mysql-bin.000046 | 12262268 |
????| mysql-bin.000047 | 3583 |
????+------------------+-----------+
????2???μ?binlog?????mysql-bin.000047?????????λ?????SQL??binlogλ??
????MySQL
????$ python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000047'
?????????
????$ python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -ttbl --start-file='mysql-bin.000047'
?????????
????DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-10 00:04:33' AND `id`=1 AND `name`='С??' LIMIT 1; #start 3346 end 3556
????DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-10 00:04:48' AND `id`=2 AND `name`='С?' LIMIT 1; #start 3346 end 3556
????DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-10 00:04:51' AND `id`=3 AND `name`='С??' LIMIT 1; #start 3346 end 3556
????DELETE FROM `test`.`tbl` WHERE `addtime`='2016-12-10 00:04:56' AND `id`=4 AND `name`='С??' LIMIT 1; #start 3346 end 3556
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11