Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I repair an InnoDB table?

We (apparently) had poorly executed of our Solaris MySQL database engine last night. At least some of the InnoDB tables are corrupted, with timestamp out of order errors in the transaction log, and a specific error about the index being corrupted.

We know about the tools available for MyISAM table repairs, but cannot find anything for InnoDB.

Side note: attempting a table optimize (in my attempt to rebuild the corrupted index) causes the database server to crash.

like image 639
lefticus Avatar asked Oct 22 '08 15:10

lefticus


People also ask

What causes InnoDB corruption?

InnoDB corruption. Most InnoDB corruptions are hardware-related. Corrupted page writes can be caused by power failures or bad memory. The issue also can be caused by using network-attached storage (NAS) and allocating InnoDB databases on it.

Which command rebuilds tables into the InnoDB storage system?

If you need to rebuild an InnoDB table because a CHECK TABLE operation indicates that a table upgrade is required, use mysqldump to create a dump file and mysql to reload the file.


2 Answers

First of all stop the server and image the disc. There's no point only having one shot at this. Then take a look here.

like image 166
Jon Topper Avatar answered Oct 14 '22 08:10

Jon Topper


stop your application...or stop your slave so no new rows are being added

create table <new table> like <old table>; insert <new table> select * from <old table>; truncate table  <old table>; insert <old table> select * from <new table>; 

restart your server or slave

like image 20
Sandro Frattura Avatar answered Oct 14 '22 09:10

Sandro Frattura