Thursday, 28 May 2015 00:00

Recovery of corrupted MySQL tables

Rate this item
(0 votes)

b2ap3_thumbnail_iStock_000005664283XSmall.jpg

It happens that MySQL data files get corrupted and require recovery. The easiest way of checking the integrity of table is by running the following command:


CHECK TABLE messages;

That phrase is going to check for errors in the messages table. If the output data look like in the picture below, it means that the table is fine and no recovery is required.

b2ap3_thumbnail_MySQL.jpg

In some cases the Msg_text columns might display error messages. In the event of that you need to run REPAIR TABLE, and MySQL will try to fix the problem.

The myisamchk tool, that comes along with MySQL, allows you to check and repair MyISAM tables, ensuring a higher flexibility as compared to SQL commands. If there are no options displayed when the myisamchk is launched, it means that the program only checks the table for errors. A number of options in the command line allow to get an additional information or point out to the tool that it is required to start data recovery process.

The files with MyISAM tables, checked by myisamchk tool, are located in the data storage catalog and have a .MYI extension. It the data are located in the catalog /var/lib/mysql, you can check all tables in the forum database by running the following command:

myisamchk /var/lib/mysql/forum/*.MYI

Usually you can use -fast option for quick check. It indicates that only those table are subject to check which were shut down incorrectly.

The option –medium-check sets a more detailed table check, during which various errors can be found. The most through check is performed after choosing the option –extend-check, and it is really slow one. This option is used only if –medium-check cannot identify the problem.

After you have clarified for yourself that the table is corrupted, you can start recovering it. This is what for the option –recover is. Before trying to recover the table with the help of myisamchk, you need to stop the mysqld. In the event when server enters something in the table during the recovery process, the result of such intervention are unpredictable.

In some cases the myisamchk program indicates thatin this or that mode it cannot fix a problem and you have to set the option –safe-recover. Upon selecting this option the program runs additional recovery operations, though the work becomes considerably slower.

Last modified on Tuesday, 23 June 2015 13:44
Data Recovery Expert

Viktor S., Ph.D. (Electrical/Computer Engineering), was hired by DataRecoup, the international data recovery corporation, in 2012. Promoted to Engineering Senior Manager in 2010 and then to his current position, as C.I.O. of DataRecoup, in 2014. Responsible for the management of critical, high-priority RAID data recovery cases and the application of his expert, comprehensive knowledge in database data retrieval. He is also responsible for planning and implementing SEO/SEM and other internet-based marketing strategies. Currently, Viktor S., Ph.D., is focusing on the further development and expansion of DataRecoup’s major internet marketing campaign for their already successful proprietary software application “Data Recovery for Windows” (an application which he developed).

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Get Help Now

Thank you for contacting us.
Your Private Investigator will call you shortly.