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,


b. Login to admin section of WordPress blog by visiting

c. Go to, 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)

Web Page Compression: Enable gzip Encoding and Caching

Website load is one factor Google been considered to rank websites in their search engine. The next tutorial explain a step to improve loading time in your website. This step is focusing on gzip encoding and caching, it compress the content from your server to the client browser. The reduced file size is what speeds up loading time. We can use one of three ways to enable gzip encoding, php.ini, .htacess and using PHP.

You would want to check if GZip is enabled on your site using an online tool at GidZip Test. . If you see “NO” for “Web Page compressed?”, then gzip encoding is NOT enabled for your website

1. We can apply gzip compression on Apache level or Server level, simply add the following line anywhere: zlib.output_compression = on. 

2. If you want to apply gzip compresion on certain directory in your server, put the following in .htaccess file

<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
 AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
 AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
 AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
 AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
 AddOutputFilterByType DEFLATE font/truetype font/opentype

3. You have WordPress installation. Download your WordPress index.php file from your server root directory. Open it up using your favorite PHP editor. Add the following  line just below  top php:


This method requires you to  manually add that line again after a WordPress upgrade to enable gzip encoding. When upgrading your WordPress, the line you added,


will be removed from index.php

Hide the Apache Web Server Version number

There are two config directives that controls Apache version.

The ServerSignature directive adds a line containing the Apache HTTP Server server version and the ServerName to any server-generated documents, such as error messages sent back to clients.

The ServerTokens directive controls whether Server response header field which is sent back to clients includes a description of the generic OS-type of the server as well as information about compiled-in modules.

Add the following to .htaccess

ServerSignature Off
ServerTokens Prod