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 your website, excluding the cache and sessions, into a new folder. Install this new folder to the empty database just defined db3. Now edit the local.xml file including the credentials for the database db3.
In case you have just restricted the access to your Magento database, you will need to change the credentials for db3. In this process, you will need to clean the cache and launch a new Magento. This shall be installed to your website automatically.
Once all the above steps have been performed, the output of the process would be the original database present in db2 and new database present in db3 with an empty Magento installed in the same.
Once this is done, you will call the following URL.
http://www.yourdomain.com/path-to-folder/magento-db-repair-tool-1.1.php
Once the url is called, you will be asked to enter the access credentials. You will define db2 as corrupted database and db3 as the reference database.
At this juncture, you will be asked to set the table credentials for the database. When you press continue after defining the credentials, you will see the reason for having received a corrupted database as results on the screen.
Interpreting the Report
The moment you run the tool, a report will be presented to you. There is a way to interpret the report. You will see that your database never needed a fix as nothing was changed in the process of repair in the main database.
The table charset was changed. There is normally no text data present here and so you won’t have anything to worry in here. The table engine was changed from MyIsam to InnoDb which can be a major issue and you will need to ask a Magento developer to intervene and investigate the issue.
In case the tool has added a missing foreign key or field, you will need to ask a Magento developer to fix the same as it is a major issue.
Please contact us for further Magento support and assistance.