The database is the most important component in the whole WordPress CMS. Being a database-driven CMS, everything that you do on your WP site is read from and written to the database. This means that the moment your database, or any table in the database, is corrupted (in laymen terms, it means your data is not retrievable or writeable), your website will malfunction. In the worst scenario, your website may not even be accessible and you won’t be able to login to the dashboard as well.

If you have a corrupted database issue, here are the ways to fix it.

Also read: How to Set Up WordPress Using Docker in Ubuntu

Using WP_ALLOW_REPAIR

For those who are using WordPress version 2.9 and above (if you are not, I urge you to upgrade it to the latest version now), WordPress comes with a database repair feature that allows you to repair the corrupted database without little technical knowledge.

1. Connect via FTP to your website and download the wp-config.php file. It is residing at the root folder of the WordPress installation.

2. Open the wp-config.php file with a text-editor and insert this line:

WP_ALLOW_REPAIR

to the end of the file, just before the if ( !defined('ABSPATH') ) line.

corrupted-db-wpconfig-allow-repair

3. Don’t edit or change any other stuff in the wp-config.php file, unless you know what you are doing. Save the changes and upload this file back to your server. Make sure you overwrite the existing copy in the server.

4. In your browser, go to the URL https://yoursite.com/wp-admin/maint/repair.php. Don’t forget to replace “yoursite.com” with your own website’s URL. This is what you will see.

corrupted-db-repair-db

You can click either the “Repair Database” button or the “Repair and Optimize Database” button. Both will repair your database. My preference would be the “Repair and Optimize Database” option since it optimizes your database as well.

5. You should now see a bunch of code. Scroll down to the end of the page and you should see “Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.” That’s it. Your database is now repaired.

corrupted-db-repair-completed

Reload your website to see if it is working and if you are able to login.

6. Lastly, remove the “WP_ALLOW_REPAIR” line from your “wp-config.php” file and re-upload it to your server.

Also read: How to Get a Free SSL Certificate for Your WordPress Website

What if the above method doesn’t work

If the above method doesn’t work, you can try the phpMyAdmin approach.

1. Login to your web host cPanel and open the phpMyAdmin module.

2. On the left sidebar, click to select your WordPress database. (If there are multiple databases in your phpMyAdmin and you are not sure which one belongs to your WordPress site, check your wp-config.php file for the database name).

3. If you have a good idea which table is corrupted, select that particular table by placing a check beside it. If not, simply select all the tables in the list. At the end of the table, there is a dropdown bar. Click and select “Repair table”.

corrupted-db-phpmyadmin-repair-table

phpMyAdmin will then proceed to repair your table(s). Once done, go back to your website and see if everything is working fine.

Last approach

If all else fails, I hope that you did backup your website regularly. This is where your backup database comes in useful.

Image credit: WordPress by BigStockPhoto

How to Compose A New Email Directly From Your Browser [Quick Tips]

Regardless which email client you are using, when you need to compose an email, you will always need to switch to your email client and click the “Compose” button. Here is a neat trick for you to compose a new email directly from your browser.

How To Read ODT Documents Inside Your Browser

Various web services can open Microsoft Office files with ease, but what about files created with LibreOffice? The good thing is, you can also read ODT document in your browser as well.

Internet Speeds Inconsistent With Your Plan? Read This!

Have you ever wondered why your Internet speed is always not as fast as your service provider said it would be? It never hurts to examine the most common causes of slower-than-advertised Internet speeds and determine whether one of these is happening to you so that you can determine how to remedy the situation.

4 Popular Bitcoin Alternatives and How They Compare to Bitcoin

The cryptocurrencies is here to stay. Bitcoin may be receiving the most attention at the moment, but it is definitely not the only one around. There are tons of Bitcoin alternatives. Here we will take a look at the 4 popular Bitcoin alternatives and see how they compare to Bitcoin.

Save and Restore Groups of Tabs in Chrome with This Quick Trick

Looking for a way to overcome having too many tabs open? Use this quick trick to save and restore groups of tabs in Chrome without installing an extension.

How to Copy All Links on a Web Page in Firefox

Have you ever wanted to copy all links on a web page while browsing? This Firefox add-on lets you copy all links on a web page in a matter of seconds.

How to Enable Two-Factor Authentication in Buffer

Buffer has added a new 2-Step Login security feature to their web app. This tutorial will show you how to enable two-factor authentication in Buffer.

What is Password Hashing (and How Does It Work)?

If there was a breach and your encrypted password was leaked. Is your account at risk? Read on to find out how password hashing work and how it affects you.

How to Get Rid of the Stickers in Comments on Facebook

Facebook added the sticker feature in its comments section. For those who dislike it, you can disable stickers in Facebook comments in Chrome and Firefox.

How to Enable Timed Website Blocking In Firefox

There are many distractions in the Web. PomodoroFox for Firefox lets you blocks unproductive websites that you specify and be more productive.

5 Cool IFTTT Recipes to Automate Your Social Life

IFTTT has a bunch of other cool and super useful social media recipes. Check out these 5 cool IFTTT recipes to automate your social life.

TunnelBear VPN: A Beautiful Bear That Just Works

Need a VPN service? TunnelBear VPN can encrypt your Internet connection while changing your public IP address to the country of your choice. Read on for the review and giveaway.