This will most likely occur when migrating Magento from one host to another. The fix, while not so obvious and easy t find turned out to be quite easy During the installation, Magento sets two IDs to 0 in its database. However, when importing the database dump to your new host, MySQL doesn’t like this and changes these ID’s to 2, which of course is not what Magento needs to load, thus the error. The fix is quite easy — set these IDs back to 0.
The IDs, we need are for ‘admin’ in the tables:
Just open phpMyAdmin and change 2 to 0, clear Magento’s cache by deleting the contents of the /var/cache folder and Voila!
Also, it will be a good idea to check the box for “Disable foreign key checks”, when exporting it in the first place, as you will surely receive an error for this when importing
Or run this command on phpmyadmin to solve it directly :
SET FOREIGN_KEY_CHECKS=0; UPDATE `core_store` SET store_id = 0 WHERE code='admin'; UPDATE `core_store_group` SET group_id = 0 WHERE name='Default'; UPDATE `core_website` SET website_id = 0 WHERE code='admin'; UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN'; SET FOREIGN_KEY_CHECKS=1;