Tuesday, May 04, 2010

Repairing a MySQL Table

*this applies only to a MyISAM type table*

This is from the MySQL Manual.

To repair table X:

1. Lock the table
Ref: MySQL Manual

lock tables X as read;


2. flush the table

Ref: MySQL Manual

flush tables X;


3. backup the table

Copy the 3 table data files to a suitable place.

4. Repair the table

Ref: MySQL Manual

repair table X quick;


(generally, its the index which is kaput so the above QUICK is sufficient. see the link for other options).

5. Unlock the table

Ref: MySQL Manual

unlock tables;


Done (hopefully).

No comments: