Pro-Test MySQL table structure for InnoDB type recover data from IBD files

Source: Internet
Author: User

Customer's machine system abnormal shutdown, after restarting the MySQL database can not start normally, reinstall the system after the discovery of database file corruption, sad is that the customer database is not backed up in a timely manner, only to find ways to recover from the database files, look for data, test various methods, confirm the following steps are feasible:

First, to retrieve the table structure. Assuming that the table structure is not lost directly to the next
A, first create a database. This database must be no table and no matter what the operation.


B. Create a table structure. Is the same as the name of the table to be restored.

The fields in the table don't matter.

The

must be InnoDB engine. CREATE TABLE ' Test
      C, turn off MySQL, service mysqld stop.
      D, overwrite the newly-created frm file with the frm file that needs to be restored;   
      e, change My.ini   Innodb_force_recovery=1, assuming no change to 2,3,4,5,6.


F, start MySQL. The service mysqld start;show CREATE TABLE test will see the tables structure information.

Second, retrieve data

A. Set up a database to create a table based on the SQL run of the created table from the above export.
b, locate the record point. The table space of the current database should be discarded first. Separates the current IBD data file from the frm.

ALTER TABLE test DISCARD tablespace;
C. Copy the. ibd files that you have previously recovered to the new table structure directory. Causes the current IBD and frm to have sex. ALTER TABLE test IMPORT tablespace;

D. Export recovered data

Pro-Test MySQL table structure for InnoDB type recover data from IBD files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.