How to Repair WordPress Database – In 6 Simple Steps

Avatar

Bart Keating

3 comments

2019 August 7th at 5:08

fix-wordpress-database

Your WordPress database contains all of your site's information - so naturally, if it goes down, it is a very stressful experience.

And unless you have a working WordPress backup to restore from, fixing the error as soon as possible is very important. Until you do, your site will be dropping search rankings and losing valuable traffic.

Fortunately, there is an easy way to fix a WordPress database and get everything going again.

In this article, I'll explain to you how to repair your database using WordPress's inbuilt repair function. I'll also explore some of the possible reasons your database got corrupted in the first place.

But now, I'll walk you through 6 simple steps to manually repair WordPress database:

Step 1: Backup your WordPress database
Step 2: From your control panel, start phpMyAdmin
Step 3: Open your WordPress database
Step 4: Select all of the tables in your database for repair
Step 5: Start the WordPress repair process
Step 6: Verify that the repair was successful

1. Backup Your WordPress Database

Important note: Before attempting to repair your WordPress database, you should back it up.

This can be done easily using a large number of WordPress plug-ins. However, given that you probably can't access your WordPress account directly, our article on creating a manual WordPress database backup is a good place to start.

Remember, just because your WordPress database is corrupted, it doesn't mean all your data is irretrievable.

Restoring your data is possible, so it's worth having a go and protecting the data you already have.

2. From Your Control Panel, Start phpMyAdmin

Next, open your WordPress server's control panel from your hosting account.

You'll probably need to log in with the password and username you set when you created your hosting account. If you've forgotten your credentials, open a support ticket with your hosting provider to reset your password.

Once you're logged in, you'll be presented with a panel that looks something like the screenshot below.

WordPress Database Repair Open cPanel

Next, you'll need to find and click on the phpMyAdmin button.

WordPress Database Repair cPanel

If your control panel looks different, don't be concerned.

Most hosting providers use cPanel (shown here), but if your host provides another cPanel alternative or management software, that won't be a problem. No matter what control panel you have, phpMyAdmin will probably be located under a 'Databases' header.

phpMyAdmin is a Linux based database manager. It's the program most web hosts use to manage WordPress databases.

If you've never used Linux or have no code experience, don't panic. Everything's under control - you won't need any previous technical knowledge to complete this guide.

3. Open Your WordPress Database

Now that you've entered the phpMyAdmin interface, you need to select the correct WordPress database.

For most servers, this will be an extremely simple step. However, if you host more than one WordPress site from the same server, things will be less straightforward.

Look at the section on the left side of your screen. That's a list of the various databases installed on your server.

The names might look a little strange, but that's normal. Your WordPress database's name will probably contain a mix of random letters and numbers, but you'll be able to identify it as it will contain a '_wp_' for WordPress. 

WordPress Database Repair phpMyAdmin Home

Once you identify the WordPress database, select it by clicking on it.

Your internal database folders will then appear in the sidebar. This will allow you to double-check that you've selected the correct database: the folder names should all begin with 'wp_'.

WordPress Database Repair phpMyAdmin Folders

Note: if you have multiple WordPress sites on your server, there'll be more than one WordPress database.

As the database naming system is random, you'll need to expand the 'wp_posts' table and check that the names of the posts match those of the corrupted site.

4. Select All of the Tables in Your Database for Repair

Once you've opened the correct WordPress database, you need to ensure that every part of it is repaired (unless your error message told you that only one part of your database was corrupted).

To do that, go to the bottom of the main directory window and select the 'Check all' box. This will highlight all the subdirectories within your WordPress database.

WordPress Database Repair phpMyAdmin Check All

5. Start the WordPress Repair Process

Once every subdirectory is selected, open the list next to the 'Check all' field and select 'Repair table'.

Congratulations, you've now managed to start the repair WordPress database process!

But wait, before open champagne and try to log in to WordPress again, you still need to check that the repair worked.

WordPress Database Repair Repair Button

6. Verify that the Repair Worked

You'll now be taken to the repair results screen. The messages displayed here will tell you if the repair was successful. Along the top, you should see the following message:

WordPress Database Repair Success

However, even if that text appears, you still need to check the rest of the output window.

A note such as 'The storage engine for the table doesn't support repair' means the database error wasn't fixed, and it's time to try an alternative method.

Alternative Solution: Modify your wp-config.php File

The second straightforward to fix WordPress database is to modify your WordPress configuration file in order to access WordPress's built-in repair function. To modify your wp.config.php file, follow these steps:

  1. Return to your control panel and open your servers' FTP client
  2. Download the file named 'wp-config.php'
  3. Open the downloaded file in a text editor
  4. Just before the if ( !defined('ABSPATH') ) line, insert this text: WP_ALLOW_REPAIR
  5. Save the 'wp-config.php' file
  6. Upload the modified 'wp-config.php' file to your FTP server, overwriting the previous version
  7. Navigate to http://sitenamegoeshere.com/wp-admin/maint/repair.php, replacing 'sitenamegoeshere.com' with your site's URL
  8. Click 'Repair Database'
  9. Replace the 'wp-config.php' file with the original, unmodified version

If you managed to follow the first six instructions correctly, at step number seven you'll arrive at this screen:

WordPress Database Repair WP Repair Screen

If such a page doesn't load for you, verify that you managed to modify your .php file correctly and that you replaced it in the correct folder (normally your server's root directory). The bottom of your modified .php file should look exactly like this when you open it in your text editor:

WordPress Database Repair Code

One More Way To Repair WordPress Database

This one does not require any technical knowledge.

If you happen to host your website with one of the WordPress hosting providers that specialize in specifically in WordPress, the only thing that you might need to do is contact the support team.

Some of the best WordPress hosting providers have teams of the CMS experts. So they'll be able not only to diagnose your problem but to fix it as well. 

Or at least they will guide you through the process via phone or live chat.

What Corrupted Your Database?

Once you've repaired your database, it's important to determine how it got corrupted in the first place. You know, so it doesn't happen again.

These are some of the common ways your database might have been damaged:

  • Software incompatibility issues: If the PHP or MySQL version on your server is outdated, WordPress might not be able to load properly.
  • Plug-in failure: A misbehaving WordPress plug-in can easily bring your entire site down. Try toggling recently installed plug-ins to identify the culprit.
  • Incorrectly set file permissions: If WordPress isn't allowed to read certain important files on your server, it won't be able to startup correctly.
  • Hardware failure: A machine malfunction in your host's data center could damage vital WordPress files. If you find that's happening regularly, it's probably time to change host!

I recommend you use the list above to troubleshoot your WordPress site and establish how it became corrupted, If you don't, you won't be able to prevent it from happening again!


Avatar
Bart Keating

Experienced in copywriting, SEO and creative writing (journalism, blogging, poetry, lullabies etc.). Public communication bachelor and HoReCa expert. A strange sense of humor but bearable. Has a beard, a cat, a fiancee, a hedgehog, and a brand new pug.


Related posts

4 Best CMS Platforms That Are Absolutely Free Of Charge!
Avatar gfdgdgdgdgd Bart Keating

2 comments

2019 January 18th

CMS (Content Management System) platforms offer a broad range of features - such as brilliant site maintenance, workflow tools and the ability to edit...

5 Best Offshore Web Hosting Options
Avatar gfdgdgdgdgd Bart Keating

6 comments

2019 January 8th

Keeping your website compliant with the laws of your local country can be a challenge. To avoid regional legal issues (often privacy or free...

5 Best Cloud Server Backup Solutions – Keeping Your Files Safe
Avatar gfdgdgdgdgd Dani Nolan

0 comments

2019 January 30th

A server that isn’t backed up to the cloud is a ticking data-loss timebomb. Thanks to the ever-present threats of hacking and server failure,...

Top 3 Hosting Providers
Hostinger logo
9.5 /10
BlueHost logo
9.4 /10
GoDaddy logo
9.1 /10
Leave a Comment

3 comments

Chris picture
Chris

2019 July 21st

WP_ALLOW_REPAIR is wrong. it is – define(‘WP_ALLOW_REPAIR’, true);

Monique picture
Monique

2019 July 9th

What happens if you did not back up your database? Is there any other way to salvage your database?

Ehi picture
Ehi

2019 June 22nd

Thanks for this article, i have been having issues with my dabatase for over a week. It the WP_POST continuously shows IN USE and every effort to repair it has failed. I even applied everything i read here and none worked…