mysqlbinlog mysql.000010 --stop-position=662771 > /root/22.sql # 导出step2中第一个DELETE前的数据
mysqlbinlog mysql.000010 --start-position=662904 --stop-position=663027 > /root/33.sql # 导出step2中这个正常的grant授权操作语句
mysqlbinlog mysql.000010 --start-position=663310 > /root/44.sql # 导出step2中的那个正常的INSERT操作及其后面的全部SQL操作
step6 开始恢复数据
/etc/init.d/mysql start
mysql < /root/all.sql
mysql < /root/22.sql
mysql < /root/33.sql
mysql < /root/44.sql
step7 检查恢复后结果
> use hellodb;
> SELECT * from students where `StuID`=100 AND `Name`='www';
+---------+--------+-------+----------+-----------+-------------+
| StuID | Name | Age | Gender | ClassID | TeacherID |
|---------+--------+-------+----------+-----------+-------------|
| 100 | www | 100 | F | 3 | 5 |
+---------+--------+-------+----------+-----------+-------------+
> SELECT * from scores where `StuID`=8 AND `ID`=14;
+------+---------+------------+---------+
| ID | StuID | CourseID | Score |
|------+---------+------------+---------|
| 14 | 8 | 4 | 57 |
+------+---------+------------+---------+
> SELECT * from scores where `StuID`=5 AND `ID`=10;
+------+---------+------------+---------+
| ID | StuID | CourseID | Score |
|------+---------+------------+---------|
| 10 | 5 | 7 | 63 |
+------+---------+------------+---------+
可以看到恢复的效果不错。