Solving Magento “Undefined Index” error on Database Restore

If you’ve ever moved a Magento database from one server to another, perhaps taking a devel site live, you might have seen an error something like this:

a:2:{i:0;s:136:"Notice: Undefined index:  0  in /Library/WebServer/Documents/ on line 92";i:1;s:776:"#0 /Library/WebServer/Documents/ mageCoreErrorHandler(8, 'Undefined index...', '/Library/WebSer...', 92, Array)
#1 /Library/WebServer/Documents/ Mage_Core_Model_Mysql4_Config->loadToXml(Object(Mage_Core_Model_Config))
#2 /Library/WebServer/Documents/ Mage_Core_Model_Config->init(Array)
#3 /Library/WebServer/Documents/ Mage_Core_Model_App->init('', 'store', Array)
#4 /Library/WebServer/Documents/ Mage::app('', 'store', Array)
#5 /Library/WebServer/Documents/ Mage::run()
#6 {main}";}

This is Magento complaining about not finding the correct default website data. Now you might be thinking, “What’s the deal? I did a database dump and import…”

The problem is the import process to the new MySQL database.

MySQL defaults to an ID of 1. Unless explicitly told, it will silently change values of 0 to 1, thus breaking the site functionality.

To cure this problem, add this at the top of the database dump before importing:


This does just what it appears to do — tells MySQL to user 0 instead of it’s automatic value, which is usually 1.

I use Navicat, a wonderful SQL client. But it has this one little problem — it doesn’t add this particular useful phrase to the dump. By adding the above SQL command at the top of the file, a reimport fixes it. Problem solved.

Leave a Reply

You must be logged in to post a comment.