生成恢复用的SQL语句还有一个问题,就是需要把create_time后面的逗号去掉 。使用下面的命令:
sed -i -r 's/(create_time=.*),/1/g' update_test_recover.sql
查看内容如下:
UPDATE `tc01`.`update_test`SETid=1 ,user_id='ddddddddddd' ,vote_num=4502 ,group_id=2 ,status=1 ,create_time='2020-06-04 11:34:17'WHEREid=1 ;UPDATE `tc01`.`update_test`SETid=2 ,user_id='ddddddddddd' ,vote_num=5564 ,group_id=1 ,status=1 ,create_time='2020-06-04 11:34:17'WHEREid=2 ;UPDATE `tc01`.`update_test`SETid=3 ,user_id='ddddddddddd' ,vote_num=3521 ,group_id=2 ,status=1 ,create_time='2020-06-04 11:34:17'WHEREid=3 ;UPDATE `tc01`.`update_test`SETid=4 ,user_id='ddddddddddd' ,vote_num=1414 ,group_id=0 ,status=1 ,create_time='2020-06-04 11:34:17'WHEREid=4 ;..........................................................
满足了条件之后,我们执行语句:
root@localhost#mysql.sock : tc0111:33:29>source update_test_recover.sqlroot@localhost#mysql.sock : tc0111:34:14>select * from `tc01`.`update_test`;+----+-------------+----------+----------+--------+---------------------+| id | user_id| vote_num | group_id | status | create_time|+----+-------------+----------+----------+--------+---------------------+|1 | ddddddddddd |4502 |2 |1 | 2020-06-04 11:34:17 ||2 | ddddddddddd |5564 |1 |1 | 2020-06-04 11:34:17 ||3 | ddddddddddd |3521 |2 |1 | 2020-06-04 11:34:17 ||4 | ddddddddddd |1414 |0 |1 | 2020-06-04 11:34:17 ||5 | ddddddddddd |8047 |1 |1 | 2020-06-04 11:34:17 ||6 | ddddddddddd |5556 |1 |1 | 2020-06-04 11:34:17 ||7 | ddddddddddd |7166 |1 |2 | 2020-06-04 11:34:17 ||8 | ddddddddddd |3277 |2 |2 | 2020-06-04 11:34:17 ||9 | ddddddddddd |8658 |2 |1 | 2020-06-04 11:34:17 || 10 | ddddddddddd |4146 |0 |2 | 2020-06-04 11:34:17 || 11 | ddddddddddd |7906 |2 |1 | 2020-06-04 11:34:17 || 12 | ddddddddddd |512 |0 |2 | 2020-06-04 11:34:17 || 13 | ddddddddddd |7493 |0 |1 | 2020-06-04 11:34:17 || 14 | ddddddddddd |5583 |1 |1 | 2020-06-04 11:34:17 || 15 | ddddddddddd |4273 |2 |1 | 2020-06-04 11:34:17 || 16 | ddddddddddd |1117 |0 |1 | 2020-06-04 11:34:17 || 17 | ddddddddddd |3936 |2 |1 | 2020-06-04 11:34:17 || 18 | ddddddddddd |4735 |2 |1 | 2020-06-04 11:34:17 || 19 | ddddddddddd |2505 |0 |1 | 2020-06-04 11:34:17 || 20 | ddddddddddd |2523 |2 |1 | 2020-06-04 11:34:17 |+----+-------------+----------+----------+--------+---------------------+20 rows in set (0.00 sec)
恢复到了修改之前的记录,本次恢复测试完成 。
推荐阅读
- MySQL查看连接数
- Linux下的MySQL Proxy 读写分离该怎么操作?
- 数据更新删除与排序:横向对比 Python、PowerBI、Excel、MySQL
- 20000 字干货笔记,一天搞定 MySQL
- 把MySQL中的各种锁及其原理都画出来
- MySQL的用户权限管理的应用总结
- MySQL数据库运维的基本命令
- Mysql写入频繁,怎么破?这是我见过的最清晰的“神操作”
- MySQL数据库表结构快速导出成MarkDown文档
- MySQL数据库架构和同步复制流程