Have you ever witnessed a scenario where your Magento store’s database or tables got corrupt? The most sane way to fix the issue is to download Magento database repair tool and get them fixed. If you are using Magento Database backup extension you can simply reload the database from your backed up copy (easy isn’t it?) but if you aren’t using this extension you can still use Magento repair tool to repair your database.
Magento Database Repair tool compares 2 databases i.e. Corrupt and target (reference) databases. Magento database repair tool will compare and from the reference database it fixes the corrupt database. Technically it does the following:
- Check for missing tables and add them, repair corrupt tables and keep charset and engine type same
- Check for missing fields in tables then repair or fix them
- Check for broken foreign key references and get rid of inconsistent data from tables
- Check for missing indexes, foreign keys and add them accordingly
Download Magento Database Repair Tool
You will find Magento Database Repair Tool here. Always download the latest version.
Every Magento powered store should keep Magento database repair tool handy, so if discrepancies occur in their store’s database they can easily correct it without jumping into MySQL world altogether.
How To use Magento Database Repair Tool
Using Magento Repair Tool is pretty easy. Magento Repair tool requires you to install the same Magento version on clean database (new database as new install) keep this new database as reference and your store’s corrupt database as corrupted. Once this is defined you don’t have to do anything and Magento Repair tool will compare corrupt database with reference database and fix all discrepancies.
Caution: If it’s your first time don’t run this tool directly on Production. Try this on staging and if everything works out run it on production cautiously. Also put your site under temporary maintenance mode while running this tool.
Let’s begin repairing a corrupt database.
- Download Magento database repair tool archive from the download page
- Uncompress the database repair tool archive
- Put the
magento-db-repair-tool-1.1.phpinto any folder on your server
- Don’t forget to backup your existing database for emergencies.
- Clone it as new database on the same server. Let’s call it db2
- Create an empty database db3
- Either copy your entire Magento folder (without cache and sessions) into a new one and install there into db3 (By editing local.xml with credentials for the newly created db3)
- Or if you already restricted access to your Magento instance, you may just change your database credentials into db3, clean cache and launch Magento once: it will be installed automatically.
At this point you should have the clone of your original database in db2 and a brand new db3 with empty Magento installed.
- Call this url in your browser
- Enter access credentials to db2 as corrupted database and to db3 as reference database
- Set table prefixes as applicable
- Press Continue and you will see result screen where you will see what was done to the corrupted database.
What happened in the background of Magento Database Repair Tool
When you run Magento database repair tool, it will present the report and this is how you should interpret what it means:
- Your database doesn’t require any fix – you will see nothing was changed
- Only table charset was changed — usually there is no need to worry about it, especially if these tables don’t have text data
- Table engine was changed from MyIsam to InnoDb — major issue. Ask your Magento developer to investigate the issue.
- Added missing foreign key or field (or even a table!) — major/fatal issue. Ask your Magento developer to fix the issue.
Similarly, you can proceed and do the same steps on your production database and perform repair. Delete the file
magento-db-repair-tool-1.1.php from your server as soon as you are done.
We would love to hear your experiences of using Magento database repair tool, please leave us a comment and let us know. Subscribe our RSS to receive latest updates.