Corrupt WordPress Database

If you find yourself with an issue where you believe the problem lies with a corrupt database, your first reaction might be going to the phpMyAdmin and try to repair the database from there. Well that was my reaction at first. But there is an easier and safer way. Whew!

In my case it was the term_taxonomy table was corrupt and therefore crashed. My menus dissapeared and I could not add new ones. I kept getting “Could not insert term taxonomy into the database.” error. That was the first and best clue that something was wrong with the database. I did go to phpMyAdmin, selected all the tables and ran an “analyze table” command. This is a dropdown easily found at the bottom of the tables.

And true to my hunch the term_taxonomy table was carrupt. So backing everything up I was going to try to repair it from the phpMyAdmin, which would also work, but for my friends out there that don’t have access to the database or just not sure of how to use it, there is an easier way. Here are the steps:

  1. From an File Transfer Protocol (FTP) program or if you dont have access to that, you can use File Manager from you cPanel or if you dont have access to that either, you can download a file manager plugin such as this plugin: File Manager
  2. In the root directory of your WordPress instalation, navigate to wp-config.php
  3. Add this line of code just above the “That’s all stop coding”
    [php]define( ‘WP_ALLOW_REPAIR’, true ); [/php]
  4. Save the file
  5. On a new tab, visit this URL(replacing https://yoururl.com with your actual url):
    [sourcecode autolinks=”true”]https://yoururl.com/wp-admin/maint/repair.php[/sourcecode]
  6. You will see 2 otions there. 1. to repair your database and 2. To repair and optimize.
  7. Choose Repair Database
  8. Once successful, check to make sure all is fixed.
  9. Remove the code you added to wp-config.php

CONGRATS! You did it!