I have some issue with login to my admin panel. When i try to use forgot password, i dont get any email. How do i reset password, or find my old one? I am using chrome, and i use the password that is saved in there on the password list but i think i may have changed the password and not saved it. Any one?
Solved! Go to Solution.
Hello @rmoen,
I have also updated previous comment, If you have ssh access then please do following things to easy to chagne password.
Basically, you directly download it to the root of your Magento project
wget https://files.magerun.net/n98-magerun2.phar
Next set executable permissions (for UNIX users only)
chmod +x ./n98-magerun2.phar
Now when you run
php n98-magerun2.phar
You will get a list of all available commands offered by the tool.
Now for resetting a forgotten admin user password first we need to get the username of the admin user, to get that we can run
php n98-magerun2.phar admin:user:list
This will provide you a list all the available admin user, the output will look something like
+----+-----------------+-------------------------------+--------+ | id | username | email | status | +----+-----------------+-------------------------------+--------+ | 1 | admin | admin@example.com | active | | 2 | nextadmin | nextadmin@example.com | active | +----+-----------------+-------------------------------+--------+
Now to reset the password we do
php n98-magerun2.phar admin:user:change-password
You will be prompted for the username of the admin user and new password for that user.
Username:adminPassword:123456 Password successfully changed
--
If my answer is useful, please Accept as Solution & give Kudos
Hello @rmoen ,
You can reset other 2 way to reset your password
Solution 1: Reset Magento 2 admin password in phpmyadmin
Go to phpmyadmin and copy the following sql query:
UPDATE admin_user SET password = CONCAT(SHA2('xxxxxxxYourNewPassword', 256), ':xxxxxxx:1') WHERE username = 'admin';
The xxxxxxx character sequence is a cryptographic salt, it is saved in app\etc\env.php file
<?php return array ( ... 'crypt' => array ( 'key' => '525701df74e6cba74d5e9a1bb3d935ad', //cryptographic salt ), ...
Solution 2: Reset Magento 2 admin password via command line (cli)
We typed on Magento 2 root folder:
php bin/magento -h
It show the admin command line:
... admin admin:user:create Creates an administrator admin:user:unlock Unlock Admin Account ...
Magento 2 does not support reset password via command line. However, we can create a new admin account, then use the new account to reset the old one.
php bin/magento admin:user:create --admin-user='new-admin' --admin-password='!admin123!' --admin-email='info@domain.com' --admin-firstname='Jon' --admin-lastname='Doe'
--
If my answer is useful, please Accept as Solution & give Kudos
is xxxxxxxx in front of YourNewPassword the cryptographic salt? or am i only set my new password there?
I get unexpected token when i paste the key from env.php
And CONCAT , SHA2 does not exist if i write it in the sql query.
I have never done this before, sorry
Hello @rmoen ,
UPDATE admin_user SET `password` = CONCAT(SHA2('xxxxxxxxNewPassword', 256), ':xxxxxxxx:1') WHERE `username` = 'admin';
--
If my answer is useful, please Accept as Solution & give Kudos
Hello @rmoen
I would suggest you to run below SQL query either from the Phpmyadmin or from the command line tool :
SET @salt = MD5(UNIX_TIMESTAMP()); UPDATE admin_user SET password = CONCAT(SHA2(CONCAT(@salt, 'YourNewPassword'), 256), ':', @salt, ':1') WHERE username = 'admin';
Then clear the cache and check it might work !
Let me know if you still face the issue - after running this query !
Hello @rmoen,
I have also updated previous comment, If you have ssh access then please do following things to easy to chagne password.
Basically, you directly download it to the root of your Magento project
wget https://files.magerun.net/n98-magerun2.phar
Next set executable permissions (for UNIX users only)
chmod +x ./n98-magerun2.phar
Now when you run
php n98-magerun2.phar
You will get a list of all available commands offered by the tool.
Now for resetting a forgotten admin user password first we need to get the username of the admin user, to get that we can run
php n98-magerun2.phar admin:user:list
This will provide you a list all the available admin user, the output will look something like
+----+-----------------+-------------------------------+--------+ | id | username | email | status | +----+-----------------+-------------------------------+--------+ | 1 | admin | admin@example.com | active | | 2 | nextadmin | nextadmin@example.com | active | +----+-----------------+-------------------------------+--------+
Now to reset the password we do
php n98-magerun2.phar admin:user:change-password
You will be prompted for the username of the admin user and new password for that user.
Username:adminPassword:123456 Password successfully changed
--
If my answer is useful, please Accept as Solution & give Kudos
Thanks alot. Worked as a charm.