当前位置:网站首页>Solution to rollback of MySQL database by mistake deletion
Solution to rollback of MySQL database by mistake deletion
2022-06-30 19:56:00 【1024 Q】
One careless time , It was used delete from xxx Deleted several important data , I found a lot of ways on the Internet , But they are scattered , We intend to record the process of data retrieval .
It is roughly divided into the following steps
1、 see binlog Open or not
# log_bin yes ON, It means that it is opened OFF It's off , The following operations , Only for ON Effective when .show variables like 'log_bin';2、 find binlog file name
show master logs;Run the above code , Here's the picture TS1-bin.000009 Is the file name we are looking for

3、 see binlog Log location
show variables like '%datadir%';4、 According to the position obtained above , Go find TS1-bin.000009 file
5、 Enter into mysql Installation directory bin Under the table of contents , Execute the following command to start from... According to the time range of accidental deletion TS1-bin.000009 File export to sql file
mysqlbinlog --base64-output=decode-rows -v --database= Database name --start-datetime="2022-06-29 15:35:00" --stop-datetime="2022-06-29 15:45:00" C:/Users/Administrator/Desktop/TS1-bin.000009 > C:/Users/Administrator/Desktop/mysqllog.sql Here I put TS1-bin.000009 The file is copied to the desktop , Because there are spaces in the original storage path of the file , Causes command execution to fail , Can't find the path .
obtain mysqllog.sql After the document , You can open it in Notepad , Search for DELETE keyword , Find the record to delete data
6、 take DELETE The sentence is transformed into INSERT sentence , stay windows Next use vbs To achieve , Copy and save the following code as :deleteToinsert.vbs file ( Must be .vbs Format file ) And mysqllog.sql In the same directory , And then double click , Will generate mysqllogOK.sql The document is what we want INSERT sentence
'========================== ' use VBS Realization MYSQL binglog DELETE turn INSERT '========================== function replaceregex(patern,str,tagstr) dim regex,matches set regex=new regExp regex.pattern=patern regex.IgnoreCase=true regex.global=true matches=regex.replace(str,tagstr) replaceregex=matches end function'======Mysql binlog DELETE turn INSERT================'VBS open the text file Set oldStream = CreateObject("ADODB.Stream")oldStream.CharSet = "utf-8"oldStream.OpenoldStream.LoadFromFile("mysqllog.sql") 'binLog Generated DELETE Original log file oldText = oldStream.ReadText() newText=replace(oldText,"### DELETE FROM", ";INSERT INTO") newText=replace(newText,"### WHERE", "SELECT") newText=replace(newText,"###", "") newText=replace(newText,"@1=", "") newText=replaceregex("\@[1-9]=",newText, ",") newText=replaceregex("\@[1-9][0-9]=",newText, ",")oldStream.Close'VBS Save the file Set newStream = CreateObject("ADODB.Stream")newStream.Type = 2 'Specify stream type - we want To save text/string data.newStream.Charset = "utf-8" 'Specify charset For the source text data.newStream.Open 'Open the stream And write binary data To the objectnewStream.WriteText newTextnewStream.SaveToFile "mysqllogOK.sql", 2 'DELETE Turn into INSERT Later new SQL file name newStream.Close7、 Get the corresponding INSERT Execute after statement .
Reference articlehttps://blog.csdn.net/qq_36602951/article/details/120729047
https://juejin.cn/post/7028955574242902023
This is about MySQL This is the end of the article on how to solve the problem of database accidental deletion rollback , More about MySQL Please search the previous articles of SDN or continue to browse the following related articles. I hope you will support SDN more in the future !
边栏推荐
- pycharm有用快捷键
- MySQL数据库误删回滚的解决
- 说实话ThreadLocal真不是啥高级的东西
- CV+Deep Learning——网络架构Pytorch复现系列——basenets(BackBones)(一)
- pycharm从安装到全副武装,学起来才嗖嗖的快,图片超多,因为过度详细!
- 盘点华为云GaussDB(for Redis)六大秒级能力
- [multithreading] use the thread pool to implement a simple thread pool
- 6-1漏洞利用-FTP漏洞利用
- MQ advantages and disadvantages (2022.5.2-5.8)
- Why should offline stores do new retail?
猜你喜欢

闲鱼难“翻身”
Redis ziplist 压缩列表的源码解析
![[jetsonnano] [tutorial] [introductory series] [i] how to enable VNC sharing](/img/f5/3f0f69739caa22809f40cf4b7483fe.png)
[jetsonnano] [tutorial] [introductory series] [i] how to enable VNC sharing

Why must a digital transformation strategy include continuous testing?

为什么数字化转型战略必须包括持续测试?

超视频时代的音视频架构建设|Science和英特尔联袂推出“架构师成长计划”第二季

Detailed explanation of specific methods and steps for TCP communication between s7-1500 PLCs (picture and text)

Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field

Primary school, session 3 - afternoon: Web_ sessionlfi

Primary school, session 3 - afternoon: Web_ xxe
随机推荐
重复乃技艺之母
Redis ziplist 压缩列表的源码解析
【论文阅读】Trajectory-guided Control Prediction for End-to-end Autonomous Driving: A Simple yet Strong Baseline
Understanding of event queue, micro task and macro task and interview questions
成长一夏 挑战赛来袭 专属社区福利来袭~免费获得CSDN定制T恤衫
Ten percent of the time, the tar command can't parse the English bracket "()" when decompressing the file
1. 爬虫之Beautifulsoup解析库&在线解析图片验证码
Enterprise middle office planning and it architecture microservice transformation
计网 | 【五 传输层、六 应用层】知识点及例题
VR全景添加对比功能,让差异化效果展示更直观!
VoIP Push 在海外音视频业务中的应用
History, selection strategy and in-depth evaluation of note taking software
Application of VoIP push in overseas audio and video services
无线充U型超声波电动牙刷方案开发
软件工程最佳实践——项目需求分析
RP prototype resource sharing - shopping app
This morning, investors began to travel collectively
将 EMQX Cloud 数据通过公网桥接到 AWS IoT
VR全景拍摄为什么要加盟?巧借资源实现共赢
Data intelligence - dtcc2022! China database technology conference is about to open