[vc_row][vc_column][vc_column_text]If you’ve ever been locked out of the Magento admin, for whatever reason, and need to create a new user, you can do so by making some adjustments to the following sql script and running it inside phpMyAdmin, or command line (CLI). You will need to make some changes to this script, so please read below for more details.
[sql]LOCK TABLES `admin_role` WRITE , `admin_user` WRITE;
SET @SALT = “ms”;
SET @PASSWORD = “password”;
SET @PASS = CONCAT(MD5(CONCAT( @SALT , @PASSWORD) ), CONCAT(“:”, @SALT ));
SET @FIRSTNAME = “firstname”;
SET @LASTNAME = “lastname”;
SET @EMAIL = “email@example.com”;
SET @USERNAME = “myusername”;
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)
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 = @USERNAME),@FIRSTNAME);
Once you’ve made these changes you can just paste this script into the SQL section of phpMyAdmin, or run it via CLI. You should then be able to use the new user that you created to login to the Magento admin.
There are a few ways that you can add a new user in Magento when you currently do not have access to the admin. This is just one of the methods that I’ve used in the past. I will post another method in the future that requires only FTP access to the server, as well as an easy way to just reset an existing user’s password via MySql CLI and phpMyAdmin.[/vc_column_text][/vc_column][/vc_row]