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