无全量备份、未开启binlog日志,利用percona工具恢复delete的数据
当我们忘记做全量备份时,并且没有开启binlog,并执行了deletefromsbtest;数据全部丢失,要想恢复是很有难度的。今天,利用PerconaDataRecoveryToolforInnoDB工
当我们忘记做全量备份时,并且没有开启binlog,并执行了
delete from sbtest;数据全部丢失,要想恢复是很有难度的。
今天,利用Percona Data Recovery Tool for InnoDB工具(仅支持InnoDB,MyISAM不支持),可以找回被删除的数据。
原理:在InnoDB引擎,delete删除操作,,不是真正的删除物理文件上的行,而是增加一个删除的标记,我们都用过WORD吧?在修改字体的时候,有一个删除线的标记,如《MySQL 管理之道》,该工具利用这个特性,找回那些标注了删除线的数据,并存入到一个文本里,然后通过load data命令,批量插入到表里。
注:truncate不能恢复(truncate是直接清空数据行,并不是添加删除标记,你可以通过查看物理文件,执行了truncate操作,ibd文件变小,而执行了delete操作,ibd文件还跟之前的一样大),drop不能恢复(数据文件都没了,还怎么恢复?)。
一、安装Percona Data Recovery Tool for InnoDB工具
# wget https://launchpad.net/percona-data-recovery-tool-for-innodb/trunk/release-0.5/+download/percona-data-recovery-tool-for-innodb-0.5.tar.gz
二、全表删除sbtest表
delete from sbtest;三、恢复
1、提取ibd物理文件,按照每页16K,单独存放。
在这里,0-28是sbtest表的主键(id),0-29是sbtest表的索引(k)。记住这个目录数字,后面我们需要通过这个目录恢复数据。
2、生成表结构
# cd percona-data-recovery-tool-for-innodb-0.5/ # ./create_defs.pl --host localhost --port 3306 --user root --password 123456 --db test --table sbtest > include/table_defs.h-- host 主机地址
-- port 端口
-- user 用户名
-- password 密码
-- db 数据库名
-- table 表名
3、再次执行make编译命令
# cd percona-data-recovery-tool-for-innodb-0.5/ # make4、恢复删除的数据
# cd percona-data-recovery-tool-for-innodb-0.5/ # ./constraints_parser -D -5 -f pages-1410414511/FIL_PAGE_INDEX/0-28/ > /tmp/sbtest.txt-D 恢复删除的行
-5 表的文件格式,默认是Compact
(不清楚的朋友,可以用show table status命令查看)
总结:
通过上述方法,顺利的完成了delete数据恢复。在数据被删除后,切记要备份ibd数据文件,一定不要覆盖,否则都是不能完成修复的。目前该工具不支持字符串set类型。
本文出自 “贺春旸的技术专栏” 博客,请务必保留此出处

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

There are two keyboard delete keys: del (delete) key and backspace key. Backspace is also called the backspace key. This key can delete the text content in front of the cursor; and the delete key can delete characters, files and selected objects. Each time you press the del key, a character to the right of the cursor will be deleted, and the character to the right of the cursor will move one frame to the left; when one or more files/folders are selected, press the Del key to quickly delete; in some applications Select an object in the program and press the Del key to quickly delete the selected object.

The functions of the delete key are: 1. Delete characters; each time the delete key is pressed, a character to the right of the cursor will be deleted, and the character to the right of the cursor will move one frame to the left. 2. Delete files; when one or more files/folders are selected, press the Delete key to quickly delete them (move to the Recycle Bin for recovery). 3. Delete the selected object; select an object in some applications and press the Delete key to quickly delete the selected object.

Control+Alt+Delete: "Mac" mode Ctrlaltdel is a common key combination used by Windows users to open Task Manager. They usually exit unwanted applications from the manager menu to free up some space on their computer. The Control+Alt+Delete Mac variant lets you open the Force Quit menu. If Mac users want to quit the program causing the problem or view open programs, they can interact with the menu to investigate further. How to perform ControlAltDelete on Mac? If you have any malfunctioning applications, you must use this key combination to

PUT and Delete requests are used in the Form form and only support get and post methods. In order to implement the put method, we can implement it through the following three steps: 1) Configure HiddenHttpMethodFilter in SpringMVC 2) Create a post form on the page 3) Create an input item, name ="_method", the value is the specified request method. Get the value of "_method" in the HiddenHttpMethodFilter class to get the new request method. The th tag is the thymeleaf template, which means that only when employee

In Go, Panic and Recover are used for exception handling. Panic is used to report exceptions, and Recover is used to recover from exceptions. Panic will stop program execution and throw an exception value of type interface{}. Recover can catch exceptions from deferred functions or goroutines and return the exception value of type interface{} it throws.

Files deleted by delete can be recovered; because when users use delete to delete files, these files will be moved to the recycle bin and are not completely deleted. Recovery method: 1. Open the "Recycle Bin", select the file you want to restore, and click "Restore this item"; 2. Open the "Recycle Bin", select the file you want to restore, and use the undo shortcut "ctrl+z". Can.

In today's era of web development, effective and efficient table management has become very important, especially when dealing with data-heavy web applications. The ability to dynamically add, edit, and delete rows from a table can significantly enhance the user experience and make applications more interactive. An effective way to achieve this is to leverage the power of jQuery. jQuery provides many features to help developers perform operations. Table rows A table row is a collection of interrelated data, represented by elements in HTML. It is used to group together cells (represented by elements) in a table. Each element is used to define a row in the table, and for multi-attribute tables, it usually contains one or more elements. Syntax$(selector).append(co

Panic in the Go framework is used to raise unrecoverable exceptions, and Recover is used to recover from Panic and perform cleanup operations. They can handle exceptions such as database connection failures, ensuring application stability and user experience.
