elegant themes

Crash! Burn! How to repair tables in the WordPress database

| September 23, 2008 | 15 Comments

We just got a scary phone call. Don’t worry, everyone’s ok. We logged into one of our WordPress sites and, while the backend was still there, all the posts and pages and comments were gone. G-O-N-E.  Poof. Just like that. I went into the PHPmyadmin section of the control panel to look at the database and saw this error: “wp_posts” is marked as crashed and should be repaired.

After a mild heart spasm, I started searching the web furiously for a solution and thank goodness found this video, which calmly explained what to do and fixed the problem.

If you don’t feel like watching the video, here’s what I did:

1. Gather backups of everything. It is painstaking and takes a looong time, but better safe than sorry.

  • Find the most recent backup that was sent to your email via the WP-DB Backup plugin
  • Go into the PHPmyadmin in your hosting provider’s control panel, export the whole database as well as each table individually.
    [Note: The table that crashed probably won't let you export it, and will give you this ugly message: Table 'wp_posts' is marked as crashed and should be repaired]

2. in PHPmyadmin, click the checkbox next to the corrupted table (ours was wp_posts).  The table will probably say “in use”.  Use the dropdown menu at the bottom to select “repair table”.

Lessons learned

1. Backup hourly or daily and send all backups to a separate email account so you don’t have to worry about it clogging up your inbox

2. Check your blog’s overhead column in PHPmyadmin at least once a month and repair any tables with a high overhead.

Here’s to a spaz-free WordPress!

Tags: , , ,

Category: Good Blogging Practice

About Rebecca Markowitz: Rebecca Markowitz has built over 50 WordPress sites for clients as Web Project Manager and WordPress specialist at illuminea. illuminea is a Jerusalem-based boutique web agency. WPGarage shows my dedicated relationship with WordPress over the years - full of love, laughs, tears, growth and strong drinks. L'chaim! View author profile.


Comments (15)

Trackback URL | Comments RSS Feed

  1. Augel says:

    Arrrgh! Worst nightmare, considering that when this happened to me, my latest back-up was like 6 months ago… A lot of posts have gone down the drain

  2. kral oyun says:

    ERROR 1002 ? i think there is a problem with the source of video.
    Always we are face to face with DB problems – especially while updating WP or while installing a clear version – sure it will be useful for WP users…
    <i><a href=”eglence” title=”eglence”>eglence</a></i>

  3. [...] good-blogging-practice/crash-burn-how-to-repair-tables-in-the-wordpress-d… [...]

  4. Tim says:

    THANK YOU THANK YOU THANK YOU (and yes, I am shouting that!) worked like a charm….

  5. adhi says:

    my blog is back!! thank you very much..

  6. Rosie Peters says:

    I cannot thank you enough. You have saved me doing some drastic things.
     

  7. Soldiweb says:

    A huge thank you!!!! this article made my day!

  8. [...] good-blogging-practice/crash-burn-how-to-repair-tables-in-the-wordpress-database… http://www.howtodothings.com/video/fixing-wp-mysql-crashed-tables [...]

  9. Rob Elings says:

    Hey there, thanks soooooo much! I couldn’t believe my eyes when I saw ALL my posts were gone (aaaaaaargh).
    Your solution worked after trying others, with no results. Thanks again!
    Rob

  10. Tim says:

    Just wanted to say thank you!  This article helped me restore my website and got things back to normal.  I am going to back up more often.  This was a good learning experience.  Luckily, I had to do was repair the wp_posts file and everything was good to go.  Thanks again!

  11. Rozenn says:

    Well…I had this same problem 2 days consecutive. Each post database crashed on my 2 blogs, both hosted on my main website root.
    Pfuh…that was very very stressy at first sight.
    This repair function saved twice my precious online datas :-))) It is very effective.
    But, when I was searching for a solution, I also read around that in some cases , the simple repair function was not enough for various dark reasons.
    There is the real deal.
    So yes. I totally agree : put the WP back-up plugin + back up your MySql database very regularly if you post often.
     
     
    But, now …as I doubt it will not happen again, I would like to know WHY ????
    There must be a reason…I found out that space could be a problem, a plugin conflict..
    Did you find out the reason ?
    If it is a space problem, how do I check this ?
    Thank you and wishing it will not again,
    Cheers,
     

  12. ForestWander says:

    You guys are awesome. I have been freaking out since this morning. For some reason this happened to my posts table as well. Thanks so much for sharing.

  13. I don’t know how to thank you enough. You just saved my 1 and half years of work. Great finding, thanks again.

  14. Chetan says:

    Your Tip Worked on WordPress Blog that had Crashed. Thanks.

  15. [...] “error establishing a database connection” even after the reboot. After many tries, this worked for me. Basically, my options table (prefix_options) was broken. Fixing it using phpMyAdmin [...]

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.

More in Good Blogging Practice (4 of 14 articles)