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.