???????????????
????MySQL?????????????????
???????????10??С??ī???????drop??????????
?????????????????????????????????????binlog?????????????
??????????????
?????????????sql????м????CHANGE MASTER???binlog???????λ???????????binlog????????????
??????mysqlbinlog??????????binlog????????sql?????????????е?drop???
???????????????????binlog????????sql???????????????????????
????????????????

???????????????
????1. ???????
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT??
`name` char(20) NOT NULL??
`age` tinyint(2) NOT NULL DEFAULT '0'??
PRIMARY KEY (`id`)??
KEY `index_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8
mysql> insert student values(1??'zhangsan'??20);
mysql> insert student values(2??'lisi'??21);
mysql> insert student values(3??'wangwu'??22);
????2. ???????
????# mysqldump -uroot -p -B -F -R -x --master-data=2 test|gzip >/server/backup/test_$(date +%F).sql.gz
?????????????
????-B ????????
????-F ??????
????-R ????洢?????
????-x ????
????--master-data ?????????????CHANGE MASTER??????binlog?????λ??????
????3. ????????????
????mysql> insert student values(6??'xiaoming'??20);
????mysql> insert student values(6??'xiaohong'??20);
???????????????????test?????
????mysql> drop database test;
?????????????????????????????д?????????binlog?У???????????
????4.??????????????binlog???
????# cd /server/backup/
????# ls
????test_2016-08-02.sql.gz
????# gzip -d test_2016-08-02.sql.gz
????# grep CHANGE test_2016-08-02.sql
????-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000003'?? MASTER_LOG_POS=107;
???????????????binlog???λ?????mysql-bin.000003??107?У??????????????binlog????е???????????????????????sql???????
????5. ???binlog??????????sql????????е?drop???
????# cp /data/3306/mysql-bin.000003 /server/backup/
????# mysqlbinlog -d test mysql-bin.000003 >003bin.sql
????# ??vim??????????drop???
???????????????????????binlog???????????????????У??????д?????binlog????????????????????????????
????6. ???????
# mysql -uroot -p <test_2016-08-02.sql
# mysql -uroot -p -e "select * from test.student;"
+----+----------+-----+
| id | name     | age |
+----+----------+-----+
|  1 | zhangsan |  20 |
|  2 | lisi     |  21 |
|  3 | wangwu   |  22 |
+----+----------+-----+
//???????????????????
//??????003bin.sql??????????????????????????????????
# mysql -uroot -p test<003bin.sql <span style="color: #3366ff;" data-mce-style="color: #3366ff;"><-????????????????
</span># mysql -uroot -p -e "select * from test.student;"
+----+----------+-----+
| id | name     | age |
+----+----------+-----+
|  1 | zhangsan |  20 |
|  2 | lisi     |  20 |
|  3 | wangwu   |  20 |
|  4 | xiaoming |  20 |
|  5 | xiaohong |  20 |
+----+----------+-----+
???????
?????塢С??
??????????SQL??????????????????????????????????崻???????
???????????????????????????????
????????????????????£???????????????
??????????????????????????????????????????????SQL?????????????????????SQL??????????????????λ????????????????