How to reset lost admin password in Magento 2?

You can use Magento CLI to create new admin user with the following command, then you can go and change password of your original user.

Execute this from the root of your magento installation:

php bin/magento admin:user:create --admin-user="admin" --admin-password="123123q" --admin-email="[email protected]" --admin-firstname="Admin" --admin-lastname="Admin"

Run below query to direct database.

An example is for reset password for admin user.

UPDATE admin_user SET `password` = SHA2('NewPassword', 256) WHERE `username`='admin';

NewPassword: Replace it with your password.

I hope it will work for you. Let me know if you any difficulty.


There should be no equal signs or square brackets like this:

php bin/magento admin:user:create --admin-user mys_username --admin-password mypass123 --admin-email [email protected] --admin-firstname john --admin-lastname cage