Magento eCommerce Blog » Podcast Feed

Magento eCommerce Blog » Podcast Feed


How to Repair the Database of your Magento Website?

March 28, 2014

Magento is quite a functional platform for developing your eCommerce websites. You will see that this platform serves you with customizable themes that you can tender to your eCommerce needs. This platform is quite able in terms of debugging, ensuring proper backup and makes sure the ROI you obtain as part of your eCommerce deal is high.
This platform even provides various methods to ensure that you can maintain the required speed and enhance the performance time and again. By now you know what to consider when hosting your eCommerce site based on Magento. Please read our post on How to optimize Magento MYSQL database with Log Cleaning?
Here we will discuss what you need to do when your database gets corrupted. Imagine a situation when you database stops working? Your eCommerce world comes to a standstill when this happens, and you are not sure what to do next to revive your site! This is where a particular Magento program known as the Magento repair tool comes to your rescue.
In case you are using the Magento database backup extension, then you can automatically load in the last stored backup. But, in case you are not using the same, you will need to use the Magento repair tool.
How does this Magento DB repair tool work for you?

Before moving on to understanding what you need to do when using this program, you need to understand how the extension works internally.
Magento Database Repair tool begins with comparing two different databases i.e. the corrupt and target which means the reference database. When the comparison happens, the Magento tool takes a note of all the corrupt files from the reference database and tends to repair the bugs. What it actually does is follow these few steps to repair the database structure.

First it will check for the missing tables. At this time it will fix the missing tables by adding them, in case they have corrupted it will repair them. All this is done keeping the charset and engine type same.
The next step is to find missing fields in the table and fix them. It will also check for broken foreign key references. At this point any inconsistent data found by the tool would be repaired and removed.
Finally it will check for missing indexes in the corrupt database while referring to the reference database. It will add the indexes and the foreign keys according to the reference database.

How to Use it?
In case, you are a fully powered store you should ideally load this program as part of your store. It will help you correct the database without having to access the MYSQL world. This is highly useful when you database gets corrupted. It is a pretty simple tool to use.
All you need to do when using this tool is install the same Magento database, which the tool will use as reference database. Along with this, the Magento site would also possess the corrupt database. The tool would define the corrupt and reference database as you load it. Once you are done with defining, Magento would compare the database to fix the corrupt database.
Make sure you don’t use the tool on production when it is your first time with the tool. First implement the tool on staging. Only when you realize that it works fine can you run it on production. Make sure you put the site on maintenance when you are running this tool.
Repairing a Corrupt Database
When using the tool to repair the corrupt database, you will have to first download the program called Magento Database repair tool from the official Magento Commerce’s download page. Once you have downloaded the tool, you should uncompress the tool archive.
You will now have to put the .php file of the Magento repair tool in any folder on the server. Before you perform the task of repairing corrupt database, make sure you have taken a backup of your existing database just for the sake of emergencies.
Now the new database you just uploaded should be defined as db2. At the same time, create an empty database db3. Your next task would include copying Magento folder of yo[