????3??????λ?????????????????????sql??????????????λ????257427-504272???(binlog2sql?????????????????????start position)???????λ?ù??????? -B ?????????sql???????sql????????(???????????£????????SQL?????????????????????grep????????)
shell> python binlog2sql/binlog2sql.py -h127.0.0.1 -P3306 -uadmin -p'admin' -dtest -tuser --start-file='mysql-bin.000054' --start-position=257427 --stop-position=504272 -B > /tmp/rollback.sql
rollback.sql ?????
INSERT INTO `test`.`user`(`addtime`?? `id`?? `name`) VALUES ('2016-12-14 23:09:07'?? 24530?? 'tt'); #start 257427 end 504272 time 2016-12-26 11:44:56
INSERT INTO `test`.`user`(`addtime`?? `id`?? `name`) VALUES ('2016-12-12 00:00:00'?? 24529?? 'С??'); #start 257427 end 504272 time 2016-12-26 11:44:56
...
INSERT INTO `test`.`user`(`addtime`?? `id`?? `name`) VALUES ('2014-11-11 00:04:48'?? 2?? 'С?'); #start 257427 end 265754 time 2016-12-26 11:44:56
shell> wc -l /tmp/rollback.sql
16128 /tmp/rollback.sql
????4????????????sql???????л????????mysql????????????
????shell> mysql -h127.0.0.1 -P3306 -uadmin -p'admin' < /tmp/rollback.sql
????mysql> select count(*) from user;
????+----------+
????| count(*) |
????+----------+
????|    16389 |
????+----------+
????TIPS
????· ????????????????????????????SQL??
????· ????????????????ι?????????λ??????????????
????· ????????????д?????????sql?в?????????????????????????????????????????????????????????????ж??
????· ??л??sql????б????????????????????????????????????????仯?????????????????????м?(????????)?????????????????????????????????2??ò??????????
????· ????????????????????й????????????????????????????????????????????
????· ?????????仯??????????????????????????(??????)??
???????????????????????????SQL??????????
???????????
????MySQL??????????????????????????????2012?????????????patch??????????????·???????(????·???????????????????)????????????????????????patch?????????????????????????????????????????????????ж?λ????????mysql?汾?????????????????????????????????·??
?????????Щ??????????????????????
????· ?????????patch???????????????mysqlbinlog?С?????????patch??????
???????
?????????????mysqlbinlog??е??????????????????????????????????????δ???п????????????
????????????????
???????
??????????????????????????binlog????????????????????????????????????????????????????á??????ж?λ?????????mysql5.5??5.6??5.7??????patch???????????????????????????????????
????????????1??????Ч???????????У???????????????patch?????????????????????????????????????????????????????????????DBA???????mysql??????????????
????????????鷳???????mysql??????????????ɡ?
??????Щ????????????????????п????????
????· ??????????????????α???slave???binlog?????д??????binlog2sql??????
???????
??????????á?α???slave??binlog????????????????????????????????????????????????MySQL?汾???????????Щ?????????????????????????????
????????1???????С??????????????DBA??????????????????????
???????????ü???
???????
??????????MySQL server??
????· ??????????????????mysqlbinlog??????????????binlog?????????????????????????滻??
???????
???????д????????????????????????????
???????????ü???
????????????????
???????
???????????á?
???????????á?
???????????????????????????????????????????binlog2sql????????????mysqlbinlog??
????????DDL??flashback
??????????????flashback?????DML???????????????????????DDL??????????????binlog???????????????????row???£?binlog????DDL???????????????????仯??????DDL???????????????MySQL???????????DDL????????????????ж??mysql????汾?????DDL??????????????????????????patch??MySQL?????MariaDB???????ú???????DDL??flashback?????DDL????????????????????洢?????????????????????????????????