Wednesday, February 11, 2015

404 error Page not found when accessing the Admin login page

I have encountered the following error message:

404 error: Page not found.

Then, I looked at the system.log file:

# tail var/log/system.log

2015-02-11T18:41:01+00:00 ERR (3): Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /var/www/html/magento1.9.1/app/code/core/Mage/Core/Model/App.php on line 634 and defined  in /var/www/html/magento1.9.1/app/code/core/Mage/Core/Model/Store.php on line 453

2015-02-11T18:41:01+00:00 ERR (3): Recoverable Error: Argument 1 passed to Mage_Core_Model_Store_Group::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /var/www/html/magento1.9.1/app/code/core/Mage/Core/Model/App.php on line 654 and defined  in /var/www/html/magento1.9.1/app/code/core/Mage/Core/Model/Store/Group.php on line 275

The cause of the problem turned out to be I have used Navicat to dump the MySQL database instead of the built-in mysqldump tool. When using Navicat to dump the MySQL database, it did not include the following command:

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

Which caused some of records in some table to have the wrong data of the primary key.

You can either:

1. use the built-in mysqldump tool to dump the MySQL database again and make a restore.

2. use the following queries to update the records:

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;

Be sure to clear your cache:

# rm -rf var/cache/*

Reference:

http://stackoverflow.com/questions/5178066/error-404-not-found-in-magento-admin-login-page

No comments: