user-avatar
Today is Friday
November 22, 2024

Tag: myisamchk

September 23, 2009

how to repair a mysql table using myisamchk

by viggy — Categories: Uncategorized — Tags: , , , Leave a comment

For some very easy repairs, this utility can be used.

myisamchk is an table-maintainence utility. It is used to repair corrupted mysql tables.

First, try myisamchk -r -q tbl_name (-r -q means “quick recovery mode”). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed. Start repairing the next table. Otherwise, use the following procedure:

1.

Make a backup of the data file before continuing.
2.

Use myisamchk -r tbl_name (-r means “recovery mode”). This removes incorrect rows and deleted rows from the data file and reconstructs the index file.
3.

If the preceding step fails, use myisamchk –safe-recover tbl_name. Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower).

Courtsey: http://dev.mysql.com/doc/refman/5.1/en/repair.html