Magento Database Repair Tool compares 2 databases (corrupt and target), then updates the target database so it has the same structure as the corrupted database.
About the Repair Tool
This tool is used to fix the database of an existing Magento installation which has one or some of these errors: missing tables, missing fields, inconsistent data from tables, missing foreign keys and indexes.
Step 1: Limit Access to Website
You should restrict access to your website while repairing the database. The following example restricts your Magento instance to your IP address exclusively. Other visitors, including search spiders, will get the HTTP “503 Service Unavailable” error.
Step 2: Create a Rewrite rule
- Create a file named 503.php in Magento root which contains the code below:
<?php header('HTTP/1.1 503 Service Unavailable'); header('Content-Type: text/plain; charset=UTF-8'); echo "503 Service Unavailable";
- Add the following rewrite rule in .htaccess or in Apache server configuration. Replace the IP address xxx\.x\.x\.x (xxx.x.x.x) with your own IP address.
#FileETag none RewriteEngine On RewriteCond %(REMOTE_ADDR) !^xxx\.x\.x\.x$ RewriteRule !503.php /503.php L
- Save the .htaccess file or reload the Apache configuration. Your site will be down until the end of the process when you restore its original state.
Step 3: Install the Database Repair Tool
- Download the archived Magento Database Repair tool from the Magento Community Edition download page.
- Upload the archived file to your server, and extract it to any folder, or extract the archive. Then, upload the file magento-db-repair-tool-1.2.php to any folder on your server.
Step 4: Backup and Clone your database
- Back up your existing database which has the problem. (The database 1)
- Clone the “database 1” as the new “database 2” on the same server
- Create new empty database (database 3)
- Then do one of the following:
- Copy the entire Magento folder (without the cache and sessions) to a new location, and install “database3.” Then, update the local.xml file with the database credentials.
- Since access to the site is restricted, you can update the database credentials to “database3” for the current Magento instance. Then, clean the cache and launch Magento. The new database will be installed automatically.
Now you have “database2,” which is a clone of your original database, and a Magento installation with the empty “database3.”
Step 5: Run Database Repair
- Now run http://url-of-your-server/path-to-folder/magento-db-repair-tool-1.0.php
- Enter access credentials to “database2” as “corrupted” database and to “database3” as “reference” database
- Set table prefixes, if applicable
- Press Continue and you will see result screen where you will see what was done to the “corrupted” database.
Step 6: Examine the results, perform the repair, remove the database repair file, and restore access to your website.
How Magento Database Structure will “take over” your job
How to Create the Magento Database Schema
A Detailed Comparison between Magento Community and Enterprise Edition