magento data with no admin

Today our team installed Magento 1.9 with sample data provided by Magento but the sample data provided by Magento didn’t have any admin login. So our team spent 30 mins to write a mysql script which we thought we must share with the community to save time for others.

Create Magento admin user

The below query helps generating MD5 salt password which you can use in the second query

SELECT CONCAT(MD5('scPassword'),':sc');

This query creates Magento admin login using MD5 salt password created in the first query

INSERT INTO admin_user SELECT NULL user_id, "Scommerce" firstname, "Mage" lastname, "core@scommerce-mage.co.uk" email, "scommerce.mage" username, "2f1b735b076352461bf8064f0953822e:sc" PASSWORD,
NOW( ) created, NULL modified, NULL logdate, 0 lognum, 0 reload_acl_flag, 1 is_active, (SELECT MAX(extra) FROM admin_user WHERE extra IS NOT NULL) extra,
NULL rp_token, NOW() rp_token_created_at, NULL failures_num, NULL first_failure, NULL lock_expires;

This query associate adminstrator role with the Magento admin login created in the second query

INSERT INTO admin_role SELECT NULL role_id, 1 parent_id, 2 tree_level, 0 sort_order, 'U' role_type, (SELECT user_id FROM admin_user WHERE username = 'scommerce.mage') user_id, 'Administrators' role_name, 1 gws_is_all, NULL gws_websites, NULL gws_store_groups;

Reset Password for Magento admin user

The below query helps generating MD5 salt password which you can use in the second query

SELECT CONCAT(MD5('scPassword'),':sc');

This query reset Magento admin password using MD5 salt password created in the first query

Update admin_user set password = '2f1b735b076352461bf8064f0953822e:sc' where username='scommerce.mage';

N.B – In both scenerios above, the username is scommerce.mage and password is Password

That’s it, it is as simple as that. Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.

Similar Posts