I have installed magento on one of my site but I am not able to login in to the admin of site. Database table 'admin_user' is empty. It give me error:

    Access denied.

enter image description here

How can login into admin of site?

What I already did:

  1. Imported table 'admin_user' from local and inserted data on live database. It didn't work.
  2. Gone through these links: http://www.crucialwebhost.com/kb/how-to-reset-your-magento-password/, https://wiki.magento.com/display/m1wiki/Resetting+the+admin+Password
  3. Checked https://magento.stackexchange.com/ questions related to admin login issue.

Error produce:

  1. I created a database and imported sample data into it.
  2. Install a fresh magento site and after installing I used database created in 1st step and all these are on same hosting.


  1. Fresh magento version
  2. Sample data version used
  3. I have to do this because I could not install magento on sample database table.
  4. Front-end working fine except few images are not displaying but thats not a issue here.

Anyone might have faced such issue or may face sometime. So what are the ways to login to admin of site?

  • 1
    Do you have data in "admin_role" table ? Any record with role name as "Administrators"? Commented Oct 27, 2015 at 4:36
  • No. though i added myself but this table was empty.
    – Jarnail S
    Commented Oct 27, 2015 at 4:37
  • You could create an admin user with magerun if you have it installed
    – scrowler
    Commented Oct 27, 2015 at 4:45
  • @RobbieAverill How? I already done. please check my 1st step under "What I already did:"
    – Jarnail S
    Commented Oct 27, 2015 at 7:44

3 Answers 3


In the admin_rule table there should be an entry with record

INSERT INTO `admin_rule` (`rule_id`, `role_id`, `resource_id`, `privileges`, `assert_id`, `role_type`, `permission`) VALUES
(1, 1, 'all', NULL, 0, 'G', 'allow');

For admin_role table

INSERT INTO `admin_role` (`role_id`, `parent_id`, `tree_level`, `sort_order`, `role_type`, `user_id`, `role_name`, `gws_is_all`, `gws_websites`, `gws_store_groups`) VALUES
(1, 0, 1, 1, 'G', 0, 'Administrators', 1, NULL, NULL);

And create one admin user from root file using below script and try to login with that detail and see if that work.


# Create New admin User programmatically.

try {
    $user = Mage::getModel('admin/user')
                'username' => 'admin1',
                'firstname' => 'Admin',
                'lastname' => 'Admin',
                'email' => '[email protected]',
                'password' => 'admin123',
                'is_active' => 1
catch (Exception $e) {
    echo $e->getMessage();

//Assign Role Id
try {
    $user->setRoleIds(array(1))  //Administrator role id is 1 ,Here you can assign other roles ids
catch (Exception $e) {
    echo $e->getMessage();

echo "User created successfully";
  • It seems to work but get new error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_name.admin_assert' doesn't exist, query was: SELECT r.*, a.assert_type, a.assert_data FROM admin_rule AS r LEFT JOIN admin_assert AS a ON a.assert_id = r.assert_id
    – Jarnail S
    Commented Oct 27, 2015 at 8:15
  • Just checked. 2 tables are missing there: adminnotification_inbox and admin_assert
    – Jarnail S
    Commented Oct 27, 2015 at 8:18
  • I uploaded these 2 tables from my local installation and it worked. thanks to you.
    – Jarnail S
    Commented Oct 27, 2015 at 8:31
  • Yes, will do for sure.
    – Jarnail S
    Commented Oct 27, 2015 at 19:30
  • I use magento 1.8, there is no table called "admin_rule" only "mageadmin_rule"
    – Black
    Commented May 25, 2018 at 8:29

Open your phpmyadmin from your host try once this sql command.
Run this Sql

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';

Now admin can able to login.
please follow this admin page shows 404 page not found


Change as per your need username is 'myuser' and password is 'password' and don't forget to clear cache

simply, create new user:

LOCK TABLES `admin_role` WRITE , `admin_user` WRITE;

SET @SALT = "rp";
SET @PASS = CONCAT(MD5(CONCAT( @SALT , "password") ), CONCAT(":", @SALT ));
SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;

INSERT INTO `admin_user` (firstname,lastname,email,username,password,created,lognum,reload_acl_flag,is_active,extra,rp_token_created_at) 
VALUES ('Firstname','Lastname','[email protected]','myuser',@PASS,NOW(),0,0,1,@EXTRA,NOW());

INSERT INTO `admin_role` (parent_id,tree_level,sort_order,role_type,user_id,role_name) 
VALUES (1,2,0,'U',(SELECT user_id FROM admin_user WHERE username = 'myuser'),'Firstname');


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.