最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Mysql誤刪除DELETE數(shù)據(jù)找回操作指南

 更新時間:2023年05月18日 15:09:56   作者:千碩  
如果我們在數(shù)據(jù)庫中不小心執(zhí)行了類似"delete from t1"這樣的不帶where條件的語句,那么整張表的數(shù)據(jù)就全被刪除了,下面這篇文章主要給大家介紹了關(guān)于Mysql誤刪除DELETE數(shù)據(jù)找回操作的相關(guān)資料,需要的朋友可以參考下

1.查看binlog是否開啟

show variables like '%log_bin%';

2.查看數(shù)據(jù)文件存放路徑:bin-log路徑

show variables like '%datadir%';

3.找到刪除時間段的binlog,翻譯為sql

mysqlbinlog --base64-output=decode-rows -v --database=數(shù)據(jù)庫名 --start-datetime="2022-10-19 16:40:00" --stop-datetime="2022-10-19 16:450:00" "D:\Program Files\mysql-5.7.30-winx64\mysqldb\bin.000041" > d:\mysqllog.sql

4.在生成的 mysqllog.sql 文件同路徑下 ,生成將delete翻譯為insert的sql文件

linux:

cat mysqllog.sql | sed -n '/###/p' | sed 's/### //g;s//*./,/g;s/DELETE FROM/;INSERT INTO/g;s/WHERE/SELECT/g;' |sed -r 's/(@17.),/\1;/g' | sed 's/@1=//g'| sed 's/@[1-9]=/,/g' | sed 's/@[1-9][0-9]=/,/g' > mysqllogOK.sql

5、windows:

在生成的sql文件同目錄下,創(chuàng)建.vbs文件,寫入如下內(nèi)容,并雙擊執(zhí)行

'==========================
'用VBS實現(xiàn) MYSQL binglog DELETE轉(zhuǎn)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轉(zhuǎn)INSERT==========
'VBS打開文本文件
Set oldStream = CreateObject(“ADODB.Stream”)
oldStream.CharSet = “utf-8”
oldStream.Open
oldStream.LoadFromFile(“mysqllog.sql”) 'binLog生成的DELETE原日志文件
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保存文件
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 object
newStream.WriteText newText
newStream.SaveToFile “mysqllogOK.sql”, 2 'DELETE轉(zhuǎn)成INSERT以后的新的SQL文件名
newStream.Close

6、把mysqllog.sql文件和生成的windows中的.vbs放在同一個文件夾中雙擊執(zhí)行生成mysqllogOK.sql文件

7、進入mysqllogOK.sql文件刪除其中的delete保留insert再去執(zhí)行mysqllogOK.sql就成功了

8、如果binlog日志沒有開啟可以進行開啟

linux:

cd /usr/etc/vim my.cnf

log-bin=mysql-bin # 開啟Binlog 一般只需要修改這一行即可
binlog-format=ROW # 設(shè)置格式 此行可以不加 命令設(shè)置即可 詳見下方拓展
server_id=1 # 配置serverID 這一行本來就存在
systemctl restart mysqld #重啟mysql

總結(jié)

到此這篇關(guān)于Mysql誤刪除DELETE數(shù)據(jù)找回操作的文章就介紹到這了,更多相關(guān)Mysql誤刪除數(shù)據(jù)找回內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

墨脱县| 永清县| 西吉县| 贵州省| 天长市| 通化县| SHOW| 新平| 方正县| 福建省| 丰台区| 武陟县| 万全县| 博白县| 石楼县| 枣阳市| 岢岚县| 阳朔县| 西乌| 南江县| 包头市| 蒙城县| 北川| 新蔡县| 裕民县| 凤城市| 原阳县| 璧山县| 军事| 柏乡县| 三河市| 娱乐| 建水县| 灵山县| 腾冲县| 德江县| 平塘县| 那坡县| 丹东市| 陆河县| 汶上县|