一、背景
在日常开发运维中,我们可能会出现一些操作失误的情况,比如使用了错误的 sql 语句对 mysql 数据进行了 update、delete 等操作,失误操作导致数据出现问题,又或者架构设计上没有使用软删除机制,用户误删除了数据需要恢复。
那么如果出现这种情况,应该如何恢复失误/mysql 误删数据时,本文将使用几种常用方法一步一步带你回滚误删/误操的数据
二、准备测试数据
1. 创建测试表
create table jxy_pms.test_model
(
create_time bigint unsigned default 0 null,
update_time bigint unsigned default 0 null,
delete_time bigint unsigned default 0 null,
test_model_id varchar(255) not null
primary key,
name varchar(255) null,
remark varchar(255) null
)
collate = utf8mb4_unicode_ci;
2. 创建测试数据
insert into test_model (test_model_id, name, remark)
values ('1','test1','test-1'),
('2','test2','test-2'),
('3','test3','test-3');
select * from test_model
test_model_id name remark
1 test1 test-1
2 test2 test-2
3 test3 test-3
三、模拟误操作
delete from test_model
四、数据回滚
见原文地址
原文地址
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦