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

Identity Theft on The Internet: Can You Prevent It?

What if someone else had enough information about you from the web to become you? What can you do to prevent identity theft? We’re here to help you out.

What You Need to Know About Future Web Standards (That are Making the Internet Better)

The Internet started 40 years ago and many things have changed since then. Let’s take a look at the future web standards and how they improve the Internet.

Internet Censorship: How Countries Block Their Citizens from Entering Websites

Some countries carry out Internet censorship and block their citizens from entering websites. How do they do this? Here’s the answer.

Internet Regulation: Is it Going to Happen Soon? What Can You Do About It?

If one country could ban a website from its borders, what prevents other countries from doing the same? Can Internet regulation ever be good?

Big List of Tools and Services to Help You Read Everything Faster

With the overwhelming information in the Internet, it has become necessary for us to read faster. Here are some tools to improve your reading speed.

Reader vs iReader: The Battle of the Readability Extensions

Reader and iReader for Firefox are two great extensions to implement a “Reader mode” in Firefox, but which is better? Let’s find out.

How to Open Multiple Links in Firefox

If you always have a set of URLs that you want to load whenever you run the browser, Multiopen for Firefox allows you to open multiple links quickly and easily.

Firefox – Which Variant Should You Use?

With the open-source nature of Mozilla’s Firefox, there are many variants that you can use. The question is, which one is the best and which should you use?

How to Transfer the Contents of User Profiles in Firefox

If you are trying out a new Firefox-based browser, you can transfer the content of your old user profiles so all your items are intact. Here’s how to do it.

How to Get Cheaper Price Notifications When Shopping Within Firefox

If you’re looking for an easier way to know which online stores offer a product for a lower price, Ciuvo Price Comparison can help you do just that.

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.

Todoist Review: Get Organized and Boost Your Productivity

Want to get organized and boost your productivity in the new year? Todoist can help and now is your chance to win a one-year premium subscription.