You also may also came across a difficult situation where you lost admin login credentials to your magento store and no way to fix it. In this article, I’m going to describe how you can add a magento admin user directly to the database through command line or PHPMyAdmin. What you need to do this is, you need direct access to mysql database through command line or PHPMyAdmin. Simply customize bellow script by adding your mysql logins etc instead of the parameters set in the query.
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@example.com','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'); UNLOCK TABLES;
Most of above terms are trivial. But bellow lists will help you not keep track of things and not to miss out.
1. Salt portion of your password. You’ll rarely need to change this. If you do, just use two lower case letters of your choice.
2. Set your password. At least 8 characters in length and at least one digit.
3. Firstname: Enter admin’s first name.
4. Lastname: Enter admin’s last name.
5. Enter email of admin user.
6. Enter username where ‘myuser’ is set. Notice ‘myuser’ shows up in two places.
7. Enter Firstname again. This is more symbolic to label the rule.