Repair WordPress Database

When a WordPress table crash, one symptom might be that all of your posts seem to have disappeared, or perhaps all of your drafts. You may even get a message in phpMyAdmin telling you that one of your tables haves crashed. No need to worry. Repairing tables is very easy.

Warning : backup the WordPress database  before attempting to repair tables

1. phpMyAdmin

a. Login to phpMyAdmin and select the affected database
b. Check the boxes by the tables that need repair.

repair WordPress database with phpMyAdmin (click to see the screenshot)

2. WordPress built-in Repair Tool

Many users  are not aware about WordPress’s built-in database repair and optimize functionality, as it is not available in admin back-end. This feature available in WordPress 2.9 and later

Repair WordPress database with WP built-in repair tool (click to see the screenshot)

a. Simply add the following line in wp-config.php To setup the automatic database repair option,

define('WP_ALLOW_REPAIR', TRUE);

b. Login to admin section of WordPress blog by visiting http://yourdomain.com/wp-login.php

c. Go to http://yourdomain.com/wp-admin/maint/repair.php, you can see page with options to ‘Repair Database’ and to ‘Repair and Optimize Database’. Just click on one of the option.

  • If you click on ‘Repair Database’ button,  WordPress can automatically search for some common database problems and repair them.
  • If you click on ‘Repair and Optimize Database’ button, WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing.

d. You can remove step (a) after you done.

WordPress Database Optimization

WordPress is powered by PHP and depends on MySQL database; in fact, all the content, including the website settings, are stored in it. When your WordPress site is visited, the web server will query the database to retrieve all the necessary information to display. However, over time, the speed required for querying the database will increase due to the number of operations such as insert, updates, and  delete of data entries.

From time to time it is a good idea to do a little housekeeping with your WordPress installation.  MySQL databases don’t clean themselves, it will help to free up disk space and keep your database running smoothly.

As a start, try optimizing the overheads on your database as reported in phpMyAdmin. When this occurs, you need to run Optimize Table manually via WP Optimize plugin or phpMyAdmin

Warning: backup the WordPress database before making major optimization efforts

1. WP Optimize Plugin

If you’re not familiar with phpMyAdmin, then a WordPress plugin may be a safer option for you.  Those plugins will allow you to select the tables you wish to optimize and will also show you the total size of your database and how much of it can be reduced after you have completed the optimization.

WP-Optimize: This is a database cleanup and optimization tool.It does all of this without the use of phpMyAdmin (a program used to handle the administration of your MySQL servers). It will show you which tables are already optimized and the ones that need to be optimized. Select the option:  Optimize database tables. Then click the Process button below the option

WP Optimize plugin (click to see the screenshot)

2. phpMyAdmin
If you have access to phpMyAdmin, simply login to your phpMyAdmin and select the option 1: Check tables having overhead . Then at the side in the drop down box, select 2: Optimize Table,  this will take care of all of your tables at once.

Optimize tables with phpMyAdmin (click to see the screenshot)