Repairing a Crashed Table in phpMyAdmin

Posted by:

I had a nasty surprise for me tonight when I realized none of my posts were available on my blog (the one you’re looking at now!). I could log into WordPress and see everything but my posts showed a count of zero (scary!). My first thought was to restore my latest backup only to realize my backup didn’t run this week. I did have the backup from last week so I logged into phpMyAdmin and this is where I found the actual problem. When I clicked on the wp_posts table, I received the following error:

#144 – Table ‘./wp_posts’ is marked as crashed and last (automatic?) repair failed

By no means am I a mysql expert. I’m still not sure why this even happened. However, this was actually not very difficult to correct in my case (once I found the cause and a few mysql forums) and I wanted to share the steps I went through to correct this:
1. Sign into your phpMyAdmin account
2. Click on your database name on the left
3. Then click on SQL in the tabs on the top
4. In the query box enter: repair table wp_posts and then click Go. (note: you’ll need to replace wp_posts with whatever table you are having an issue with if it’s not this table)

repair-wordpress-database

For me this took a little while to finish (probably less than one minute). After that, things were working well again. Obviously, this isn’t going to work in every case but if you’re lucky like I was, maybe it will. I’m still a little nervous as to why this happened in the first place but at least I now have an up-to-date backup if it happens again!

 

13

About the Author:

Brad initially struggled with online dating but over time became quite successful using it. He met his wife using online dating and has been giving advice and helping people improve their results since 2007. He has written a Free Online Dating Guide to help others find success with online dating. You can learn more about his personal experience using online dating and running this website here.

Comments

  1. Lewis  June 17, 2010

    There’s a repair function built in to phpMyAdmin

    http://techblissonline.com/mysql-tables-corrupt-crash-repair-phpmyadmin/

    That page has instructions on doing this (not my page)

    reply
  2. Atul  December 9, 2011

    great thanks My table crashed .. mine was also posts table It drove me nuts
    But your command worked for me

    Thanks a ton 🙂
    ATUL

    reply
  3. Brad  December 19, 2011

    Happy to help 🙂

    reply
  4. Plates  August 18, 2012

    Worked a treat for me – I’d managed to corrupt a table with 7million rows in it! Would’ve taken me a fortnight to re-populate it from scratch
    Thank you!!

    reply
  5. zackf  October 20, 2012

    Thanks, this saved the day for me. For some reason the automatic repair failed, and when I initiated it manually it worked! Whew – this saved about 45,000 posts

    reply
  6. Matt  November 11, 2012

    Thanks for the fix! If you don’t have phpmyadmin, you can also just FTP up a php file that has this in it:
    ——————
    query(“repair table wp_posts;”);
    ?>
    ——————–
    Then load the php file from your browser.

    reply
    • Matt  November 11, 2012

      That didn’t post correctly. You just need these two lines surrounded by php tags:

      require(‘./wp-load.php’);
      $wpdb->query(“repair table wp_posts;”);

  7. Siby P Varkey  March 27, 2013

    Thank you very much Brad.

    I tried many ways to solve the issue of “#144 – Table ‘….’ is marked as crashed and last (automatic?) repair failed” problem with one of my site – till I try your suggestion.

    It solved my issue after giving the commands 3-4 times till it showed repair OK.

    It was a great help.

    Thank you very much

    reply
  8. Babak Naffas  June 26, 2013

    Well that was easy; I have my comments back.
    Thanks.

    reply
  9. Antonio  October 24, 2013

    Great! Thank you very much! You solved my big problem!!!

    reply
  10. Javier  March 18, 2014

    Thanks, its crazy how simple this was, my site was down for months, I figured it would be really complicated to fix.

    reply
  11. abhishek  April 7, 2014

    You saved my day!

    reply
  12. Esohe  May 20, 2016

    Thank you so much Brad! You are a life saver!

    reply

Add a Comment