Magento Tutorials

How to Reset Admin Password in Magento

Forgot your Magento admin password? No worries, in this article we’ll show you the various ways you can reset your admin password, in an order of increasing difficulty.

1. Use the ‘Reset password’ functionality

This is the most common and easy way which everyone should try as the first option.

Visit your Magento admin backend in a browser, and click the link Forgot your password.

Forgot your password Magento 2

Insert your email address, complete the CAPTCHA, and then press on the Retrieve Password button.

An email will be send to your email address, containing a password reset link.

Click the Reset Password link, or paste the link in your browser.

You then will be asked to insert a new password. Insert the password twice and click the Reset Password button to save your changes.

Now you are able to log back in with your new admin password.

2. Reset password from the Magento admin backend

In case you already know your current password, you can reset your own or another admin user’s via System > Permissions > All Users.

Here you will see a list of all currently available users (including administrators) in your Magento backend. To reset password on one, click on the respective user.

In the following panel, you’ll see options to change your current password, like so:

Put in your desired passwords and click on Save User.

Notes: Passwords must have 7 or more characters, containing both numeric and alphabetic.

3. Insert a new password using PHPMyAdmin

Alternatively, you could also insert a SQL query to make changes to a specific user in your admin_user table in your database.

To do this, let’s first log into PHPMyAdmin and choose the database which contains the data for your Magento store. And then choose SQL:

And paste the following query:

UPDATE admin_user SET password = SHA2('$PASSWORD', 256) WHERE username='$USERNAME';
  • Replace $PASSWORD with your new admin password, $USERNAME with the username you want to change the password for.

And then choose Go to execute the query and login with your admin username using the new password.

4. Use Magento CLI to create a new user

As Magento CLI does not support changing admin passwords with a command, you can create a new admin user with the following command, and then use the new admin account to change the password of your original user.

Go to your Magento directory and execute the following command to create a new admin user:

php bin/magento admin:user:create --admin-user new_user_name --admin-password new_user_password --admin-email [email protected] --admin-firstname firstname --admin-lastname lastname

where :

  • new_user_name: is the username of the new admin account that you’ll be creating
  • new_user_password: is the password of the new admin account that you’ll be creating
  • [email protected] : is the email of the new admin account that you’ll be creating
  • firstname: replace it with your first name
  • lastname: replace it with your last name

After you’ve created a new admin account, log into this new account and reset your old admin account’s password using method #2. 

5. Change the password using n98-magerun

The n98-magerun Magento management command line utility provides a plugin to create, edit, and delete users (note that some commands do not work on Windows). With this plugin you can easily change the password for an existing user.

In your Magento directory, run the following commands:

Download n98-magerun2:

wget https://files.magerun.net/n98-magerun2.phar

Make the downloaded .phar file executable:

chmod +x ./n98-magerun2.phar

Verify the installation by checking version:

./n98-magerun2.phar --version

Now that you have successfully completed the installation, change your admin password using:

n98-magerun2.phar admin:user:change-password [username] [password]

Further Reading:

Magento Admin Login Not Working: Here’s How to Fix It Completely
A Guide to Magento 2 Admin Dashboard
Add a Custom Link to Magento 2 Admin Menu
Magento images not showing up in admin or in frontend

Dom

A knowledge craver who always strive to be wiser everyday.