Skip to content

Instantly share code, notes, and snippets.

@tridungpham
Created December 4, 2013 10:28
Show Gist options
  • Save tridungpham/7785460 to your computer and use it in GitHub Desktop.
Save tridungpham/7785460 to your computer and use it in GitHub Desktop.
Create new admin user in Magento with password "admin"
INSERT INTO admin_user SELECT
NULL `user_id`,
"Dung" `firstname`,
"Pham" `lastname`,
"dungpt@sutunam.com" `email`,
"dungpt.sutunam" `username`,
"9684dfd577831f73890e88fe18ca9072:Hs" `password`,
NOW() `created`,
NULL `modified`,
NULL `logdate`,
0 `lognum`,
0 `reload_acl_flag`,
1 `is_active`,
NULL `extra`,
NULL `rp_token`,
NOW() `rp_token_created_at`
;
INSERT INTO admin_role SELECT
NULL `role_id`,
(SELECT `role_id` FROM admin_role WHERE `role_name` = 'Administrators') `parent_id`,
2 `tree_level`,
0 `sort_order`,
'U' `role_type`,
(SELECT `user_id` FROM admin_user WHERE `username` = 'dungpt.sutunam') `user_id`,
'dungpt.sutunam' `role_name`
;
@andhiirawan
Copy link

andhiirawan commented Jul 1, 2016

Tested for Magento 1.9.2.4

missing 3 columns : failures_num, first_failure, lock_expires
so it should be like this :

INSERT INTO admin_user SELECT
    NULL user_id,
    "Andhi" firstname,
    "Irawan" lastname,
    "andhiirawan@inbox.com" email,
    "andi" username,
    MD5('andi12345') password,
    NOW() created,
    NULL modified,
    NULL logdate,
    0 lognum,
    0 reload_acl_flag,
    1 is_active,
    NULL extra,
    NULL rp_token,
    NOW() rp_token_created_at,
    NULL failures_num,
    NULL first_failure,
    NULL lock_expires;

missing 3 columns : gws_is_all, gws_websites, gws_store_groups
so it should be like this :

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

@jrosell
Copy link

jrosell commented Sep 28, 2016

Working in magento 1.7.0.2

@cchamikara
Copy link

cchamikara commented Feb 2, 2017

For Magento EE 1.14.1.0 this need to change little bit

`
INSERT INTO admin_user SELECT
NULL user_id,
"Chamal" firstname,
"Chamaikara" lastname,
"chamal@google.com" email,
"chamal" username,
MD5('xoxox') password,
NOW() created,
NULL modified,
NULL logdate,
0 lognum,
0 reload_acl_flag,
1 is_active,
NULL extra,
NULL rp_token,
NOW() rp_token_created_at,
NULL failures_num,
NULL first_failure,
NULL lock_expires,
0 token_login_enabled,
NULL login_token_secret,
NULL last_token_used
;

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment