How to Repair a Crashed WordPress Posts Table

photo credit: Code & Martini by Ivana Vasilj - cc license
photo credit: Code & Martini by Ivana Vasilj – cc license

Every now and then the WordPress posts table will crash and screw up your website. Why does this happen? It’s not always clear how tables get corrupted, although it can usually be attributed to an unexpected event, such as the MySQL server or the server host getting killed in the middle of an update, causing interrupted writes to the database.

Symptoms of a Crashed Posts Table

If you navigate to the “All Posts” or “All Pages” screen in the WordPress admin and find nothing there, your first instinct is probably to freak out. What happened to all of my content?! Don’t worry; it’s still there. This is often a symptom of a crashed posts table in the database. It’s the MySQL equivalent to a throwing a tantrum, but it’s easily fixed, so you should stay calm.

You may also see blank pages or get 404s on existing pages where there should be content. Those who have BuddyPress active may also see a message like this:

“The following active BuddyPress Components do not have associated WordPress Pages: User Groups, Members, Activate, Register. Repair”

When the posts table is crashed, BuddyPress can’t find those pages, so it gives you that warning, even though you set the pages before.

How to Fix a Crashed Table

Sometimes WordPress can repair this problem automatically, but other times you’ll just have to do it manually via phpMyAdmin. Before touching anything, make sure that you have a backup of your database.

If you’re not comfortable with phpmyadmin, you should first try to use WordPress’ recommended method of database repair, available since 2.9. Add the following to your wp-config.php file:

define( 'WP_ALLOW_REPAIR', true );

That should take effect and automatically repair your crashed table after you visit the script at: {$your_site}/wp-admin/maint/repair.php

If you’re comfortable with using phpmyadmin, you may opt for an alternative method of repair, which really does the same thing as the previous method:

Log into your host’s control panel and launch phpMyAdmin. Select your database and then look for the wp_posts table. Chances are that it’s not going to look like the other tables and will probably say “In Use”:

Scary, right?!
Scary, right?!

This is the table that is bedeviling you and you’ll want to select it and then click on “Repair Table” in the dropdown:

Repair Table
Repair Table

This should have you all fixed up. Visit your site to verify that your posts and pages are back to normal. Note: This also works for other corrupted tables, i.e. wp_options, etc. It’s a fairly easy solution to a problem that presents itself as a dire emergency on the frontend of your WordPress site. File this one away for the next time you suspect a corrupted table.

Who is Sarah Gooding


Sarah Gooding is an Editorial Ninja at Audrey Capital. When not writing about WordPress, she enjoys baking, knitting, judging beer competitions and spending time with her Italian Greyhound.

There are 7 comments

Comments are closed.