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:

[php light=”true”]define( ‘WP_ALLOW_REPAIR’, true );[/php]

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.


7 responses to “How to Repair a Crashed WordPress Posts Table”

  1. The second method that say that you can repair your database table from phpadmin is more suitable for me but if i am developing a new system for someone else then it is always better to place a code inside wp-config.php file. Nice share sarah

  2. thanks for the post!
    Do you have any advise if the repair of the db-tables works, but the crash happens again and again?
    How do I find the reason for multiple crashes? In my case for wp_options


Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: