Magento 2 how to recover admin password
This shows you how to recover admin password for Magento 2. It is very common, that you forget your password. If this was the only user and you can not get a mail from password recovery, your shop is lost. No, not really. You can create new admin users by command line, so you only need ssh access to recover your shop.
Magento 2 how to recover admin password
Magento 2 default is very strict with passwords. You need to change it often and it is not possible to use an already used password twice. So you need to learn new passwords and that leads to forgetting last entered passwords. I already showed you how to change password settings, so you do not need to change passwords (perfect for development environments).
Just use the following command to create a new admin user:
1 | php bin/magento admin:user:create --admin-user="adminNew" --admin-password="123123q" --admin-email="admin@example.com" --admin-firstname="Admin" --admin-lastname="Admin" |
You should change admin-user and admin-password to your needs. If you do not change it, you can loggin now with adminNew and 123123q as password. With this admin user, you are able to set a new password for your preferred user. Logout and login again with your user.
Security information
Don’t forget to delete newly created user. Espacially if you are working on your production environment! Your password is visible in your shell history.
Conclusion
It is really easy to recover admin password. Magento 2 offers you many useful tools for your command line. admin:user:create is on of it. Detailed information on other useful tools is available in Magento 2 documentation of on your command line, just type admin and enter and you will get a table of all possible further admin related commands.