How to Use Magento Database Repair Tool

Time and again there may be the chances, where your Magento database can get distorted and you will be facing lots of errors while installing your Magento. Instead of wasting your time in fixing the database, which may wind up with an absolutely broken website, you should use the Magento Database Repair Tool, created by Magento core Team, which will surely help you in big time.

The Magento Database Repair Tool evaluates two databases i.e. reference and target. After comparing these two databases, this tool updates the target database so as to keep its structure same as the structure of reference database. This is done by performing the following methods:

  1. Adding up missing tables or restoring them to get the identical engine type and char set.
  2. Adding Missing fields or repairing them.
  3. Taking out incompatible data from tables that have broken foreign key references.
  4. Adding up missing foreign keys and indexes.

The Database Repair Tool is applied to fix the database of an existing Magento installation that contains any of the errors which are stated above. You just have to install the same version of Magento that you are using into a clean database. Use the new database as “reference” and existing database as “corrupted”.

The most important thing which you should always keep in your mind, make sure that you have tested the database repair tool on development environment before actually running it on production environment. Also, don’t forget to keep a backup of your original database prior to running database repair tool.

While the repairing process is going on, it is highly advisable to restrict the access to your website. By restricting your Magento instance to your IP address, the visitors including search spiders, will get the HTTP503 Service Unavailable error.

You have to generate a 503.php file in your Magento installation root as:

  1. <?php
  2. header(‘HTTP/1.1 503 Service Unavailable’);
  3. header(‘Content-Type: text/plain; charset=UTF-8′);
  4. echo ”503 Service Unavailable”;

After doing this, you have to add the rewrite rule in .htaccess or in Apache server configuration as follows:

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^$

RewriteRule  ! 503.PHP$ /503.PHP [L]

Where, (backslashes ahead of dots) should be reinstated with your IP-address. As you save this .htaccess file or restore the Apache configuration, your site will be down until you bring back to original status.

Here are the Steps:

  1. Download Magento database repair tool archive from the download page
  2. Uncompress the archive
  3. Locate the magento-db-repair-tool-1.0.php into any folder on your server
  4. Take Backup of your present database so that you can restore it if anything goes wrong
  5. Duplicate it as new database on the same server. Say, “database2”
  6. Create an empty database, ”database3”
  7. Copy your whole Magento folder into a new one and install it into “database3”
  8. If you have by now constrained the access to your Magento instance, change your database records into “database3”, remove all the cache and start on Magento once: it will get installed automatically.

Currently, You have the duplicate copy of your original database in “database2” and empty Magento installed in”database3”


Run http://url-of-your-server/path-to-folder/magento-db-repair-tool-1.0.php

  1. Enter access credentials to “database2” as “corrupted” database and to “database3” as “reference” database
  2. Set table prefixes, if pertinent
  3. Press “Continue” and you will see result screen where you will see what was done to the “corrupted” database.

Don’t forget to remove the magento-db-repair-tool-1.0.php. Now, you can Access your website on browser and you are done.

The following two tabs change content below.
Harshal Shah is CEO & Founder of Xhtmljunkies, Located in Gujarat, India, XHTML Junkies is one of the best companies that offer unique eCommerce solutions by the virtue of its dedicated professionals. Our professionals are extremely proficient in offering development services pertaining to eCommerce. You can find Harshal on and Twitter.