How to Repair MySQL Tables

If you suspect your MySQL database is corrupt, you can mysqlcheck command to check for corrupt table(s) in the database.
In this example, the database user is blog_dbowner and the database name is blogdb.
Run the following command to check for the database for corrupt table(s)

$ mysqlcheck -ublog_dbowner -p blogdb
Enter password:
blogdb.wp_ak_twitter OK
blogdb.wp_commentmeta OK
blogdb.wp_comments OK
blogdb.wp_links OK
blogdb.wp_options
warning : Table is marked as crashed
warning : 28 clients are using or haven’t closed the table properly
warning : Found 437028 deleted space in delete link chain. Should be 13612
error : Found 1 deleted rows in delete link chain. Should be 19
error : record delete-link-chain corrupted
error : Corrupt
blogdb.wp_pollsa OK
blogdb.wp_pollsip OK
blogdb.wp_pollsq OK
blogdb.wp_postmeta OK
blogdb.wp_posts OK
blogdb.wp_term_relationships OK
blogdb.wp_term_taxonomy OK
blogdb.wp_terms OK
blogdb.wp_usermeta OK
blogdb.wp_users OK
blogdb.wp_wordbook_errorlogs OK
blogdb.wp_wordbook_postlogs OK
blogdb.wp_wordbook_userdata OK

From here we can see that blogdb.wp_options table is corrupt.
Fix it using the following command:

$ mysqlcheck -ublog_dbowner -p -r blogdb blogdb.wp_options
Enter password:
blogdb.wp_options
info : Found block with too small length at 10308; Skipped
info : Wrong bytesec: 255-255-255 at 437868; Skipped
info : Found block with too small length at 69816; Skipped
info : Found block that points outside data file at 70372
info : Found block that points outside data file at 73076
info : Found block that points outside data file at 73544
info : Wrong bytesec: 116- 95-116 at 437668; Skipped
info : Found block that points outside data file at 232704
info : Delete link points outside datafile at 437624
warning : Number of rows changed from 328 to 273
status : OK

Reference:

How to Check and Repair MySQL Tables Using Mysqlcheck

Advertisements

One thought on “How to Repair MySQL Tables

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s