MySQL table marked as crashed

That sounds bad, and it is. But the fix in my case was pretty simple.

This happened on a WordPress instance that got slammed during load testing.

The exact error in the Apache log was:

[ERROR] /usr/libexec/mysqld: Table './weblogs/wp_options'
 is marked as crashed and should be repaired

Where weblogs is the name of my WordPress database and wp_options is a table in it.

Scary. The site itself reported a database connection error.

Fixing this required running mysqlcheck thus:

mysqlcheck -u root -p weblogs --auto-repair

I ran it first without the “–auto-repair” option because by that point I’d used up an entire day’s reserve of courage.

A more surgical method would have been to log onto the database as the root user using the mysql client and first verify the table really is broken:

use weblogs;
check table wp_options;

If it is, then you can run repair against that table alone:

repair table wp_options;

Then run “check table” again to confirm it is fixed.

Google returned a ton of hits on the query “wp_options is marked as crashed and should be repaired”, but I immediately set aside all the ones that sent you to phpMyAdmin because… life is just too short.

Here are some posts that provided the right stuff:

Unexpected WordPress Database Table Error

Mysqlcheck: Quick guide for Sys admins

How To Repair Corrupted MySQL Tables Using myisamcheck

All the above articles do a good job of providing a way to verify the problem and a means of fixing it.

This entry was posted in Database on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).