How to Repair WordPress Database when it’s Broken

Why is it needed to repair WordPress database?

Although it’s not easy to diagnose the exact reason for WordPress database failure, there are some possible answers that can cause WordPress database issues.

Sometimes hardware failures create database issues for your WordPress website and you don’t have any control over it because it is related to your server and web hosting company. Updating WordPress core files or plugins could sometimes be the reason.

If your website is hacked, you probably should repair WordPress database as your website faces some troubles and probably you can not enter your website again. To make sure about the security of your WordPress site it is better to secure your site using these best WordPress security plugins to have better protection.

In some other cases your website may have not been broken but your site loads slowly. In addition to some measures that can be taken by using LiteSpeed cache plugin to speed up WordPress site, repairing WordPress database improves the speed of your website.

One of the best things you could do to repair WordPress database easily without worries is to back up WordPress files and databases when you have a good healthy working website. There are various methods and plugins to backup a WordPress site that you should use.

How to repair WordPress database?

There are two main ways to repair a WordPress database. One of them is done through the WordPress admin menu with no need to use your web hosting control panel and the other method is done using the control panel of your web hosting.

Repair WP database using build-in repair tool

WordPress has a powerful built-in database repair tool and you can get benefit from that easily, but it’s not accessible through usual WordPress menus and you need to take some actions to do that:

Go to your WordPress files through an FTP program or a web browser and download wp-config.php file into your local computer

Open wp-config.php using any editor you would prefer. Go to the end of this file. You will see if ( !defined('ABSPATH') ) , add the following code just before that line, then save and close it. define('WP_ALLOW_REPAIR', true);

Upload the newly changed wp-config.php to your server and replace it with the previous one.

Go to the following address in your web browser http://yoursite.com/wp-admin/maint/repair.php . Make sure to replace your website address with yoursite.com

Repaire WordPress Database using WordPress built-in feature
Repaire WordPress Database

You will have two options and both options can do the job for you. Repair Database only repairs it and if you want to optimize it too (which is recommended), choose Repair and Optimize Database.

After some codes, you will see the following:

“Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.”

Reopen the wp-config.php file andremovedefine(‘WP_ALLOW_REPAIR’, true); from that and reupload it again to your server to prevent abuse by anonymous unauthorized people.

Repair WordPress database using control panel

Depending on the control panel your web-hosting offers, the image could be different, but if you are using cPanel control panel, after logging in to your control panel, you will see something like this image, click on phpMyAdmin.

Repair Tables of WordPress Database in phpMyAdmin
Repair Tables of WordPress
Database in phpMyAdmin

After entering phpMyAdmin navigate to the end of the page, mark check all to select all database records, and near it, from the drop-down menu, under Table Maintenance , click on Repair Table. It will automatically fix your database entries and your WordPress database.

After completion, you will get a message that says:

Your SQL query has been executed successfully

Now you have completely repaired your WordPress database without using any plugin or modifying any file.

You might also like
Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More