In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly tells you about the method of using MySQL binary logs to recover deleted data. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here. Let's go straight to the topic. I hope this article can bring you some practical help by using MySQL binary logs to recover deleted data.
Delete data from the MySQL table
Mysql > use sbtest;mysql > select count (*) from sbtest1;+-+ | count (*) | +-+ | 1000 | +-+ 1 row in set (0.00 sec) mysql > delete from sbtest1;Query OK, 1000 rows affected (0.21 sec) mysql > select count (*) from sbtest1 +-+ | count (*) | +-+ | 0 | +-+ 1 row in set (0.00 sec)
Confirm the time point and the current binary log file, and read the operation record from the binary log
Mysqlbinlog\-start-datetime= "2018-09-27 15:55:00"\-- stop-datetime= "2018-09-27 15:00:00"\-- base64-output=decode-rows\-- result-file=result.sql\-v / var/lib/mysql/binlog.000022
One of the records
Remove irrelevant content
Grep-A 5 "DELETE FROM\ `sbtest\'.\ `sbtest1\ `" result.sql > 1.txt
Extract data
Grep "=" 1.txt > 2.txtsed-I / G '2.txt
Use the following script to generate INSERT statements
[root@mysql03 tmp] # cat r2.sh #! / bin/bashvs= "" while read linedo n = `echo $line | awk-NF "="'{print $1}'`v = `echo $line | awk-NF "="'{print $2} '`if ["$n" = "@ 1"]; then vs= "INSERT INTO\ `echo\ ``sbtest1\ `VALUES (" $elif ["$n" = "@ 2"] Then vs=$vs "," $v elif ["$n" = "@ 3"]; then vs=$vs "," $v elif ["$n" = "@ 4"]; then vs=$vs "," $v ");" echo $vs > > 3.txt fidone "
< 2.txt[root@mysql03 tmp]# sh r2.sh 将数据导入到 MySQL 表中 [root@mysql03 tmp]# mysql < 3.txtmysql>Select count (*) from sbtest1;+-+ | count (*) | +-+ | 1000 | +-+
1 row in set (0.00 sec)
Using the MySQL binary log method to recover deleted data, let's stop here. If you want to know about other related issues, you can continue to follow our industry information. Our section will capture some industry news and professional knowledge to share with you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.