Magento Tutorials

How to Reset Admin Password in Magento 1 & 2

reset-magento-admin-password

Hi! Have you ever forgotten your Magento admin password?

In this post, I’d like to share some main ways to reset your Magento admin password.

Normally, there are 5 ways to do it:

  1. Use the ‘Reset password’ functionality
  2. Reset passwords using the Magento admin backend
  3. Change the password using “n98-magerun”
  4. Insert a new password in the database using PHPMyAdmin
  5. Insert a new password in the database using the mysql client

 

1. Use the ‘Reset password’ functionality

 

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

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

Next insert your email address and press the Retrieve Password button.

magento forgot password

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.

magento reset password

Now you are able to log back in.

2. Reset password using the Magento admin backend

 

  • In case you already know your current password, access your backend > System > Account:

 

magento reset account password

From the My Account management page, insert your current password and insert your new password twice.

After that, click the Save Account Button in the top-right corner of the page.

 

  • Reset someone else password using the Magento admin backend

 

Definitely, this method could be used if your account is granted permission to set credentials.

To reset another user credentials, insert the name of the particular user, first, select System > Permissions > Users:

magento users

From there, select the user you want to perform a password reset for. You now will be taken to the User Information page.

Next, insert your own password in the Current Admin Password field, insert a new password for the user and select Save User.

magento edit user

3. Change the password using n98-magerun

The n98-magerun Magento management command line utility provides a plugin to create, edit and delete users.

With this plugin you can easily change the password for an existing user.

Magento 1:

cd ~/public
n98-magerun admin:user:change-password <username>

Magento 2:

cd ~/magento2
n98-magerun2 admin:user:change-password <username>

This will show a password prompt. Insert the password and test if you can login on the web interface. The plugin does not ask for a confirmation, so it might be smart to test the password right after changing it.

Another way for 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:

<path_to_magento>/bin/magento admin:user:create --admin-user="admin" --admin-password="123123q" --admin-email="admin@example.com" --admin-firstname="Admin" --admin-lastname="Admin"

4. Insert a new password using PHPMyAdmin

First, log into your PHPMyAdmin:

  • Go to PHPMyAdmin on the hypernode by visiting http://appname.hypernode.io/phpmyadmin  or by clicking the link in our service panel.
  • Login with the username and password in ~/.my.cnf
  • Select the live database in the left side panel.
  • In the top bar, select the SQL tab.

Next, follow the instructions below for your Magento version:

Magento 2:

  • Paste the following query:
    UPDATE admin_user SET password = CONCAT(SHA2('$SALT$PASSWORD', 256), ':$SALT:1') WHERE username = '$USERNAME';
    • Replace $PASSWORD with the new admin password and replace $USERNAME with the username you want to change the password for.
    • Replace $SALT with a random string of characters. Use the same random string in both parts of the SQL query. The string can be as long as you want.
  • Click Go to execute the query, and login with the given username using the new password.

If your Magento 2 shop uses table prefixes add the prefix to your table name. i.e. If your table prefix is mage_, use the following query instead:

UPDATE mage_admin_user SET password = CONCAT(SHA2('$SALT$PASSWORD', 256), ':$SALT:1') WHERE username = '$USERNAME';

Magento 1:

  • Paste the following query:
    UPDATE admin_user SET password = CONCAT(MD5('$SALT$PASSWORD'), ':$SALT') WHERE username = '$USERNAME';
    • Replace $PASSWORD with the new admin password and replace $USERNAME with the username you want to change the password for.
    • Replace $SALT with a random string of characters. Use the same random string in both parts of the SQL query. The string should be just 2 characters.
  • Click Go to execute the query, and login with the given username using the new password.

If your Magento 1 shop uses table prefixes add the prefix to your table name. i.e. If your table prefix is mage_, use the following query instead:

UPDATE mage_admin_user SET password = CONCAT(MD5('$SALT$PASSWORD'), ':$SALT') WHERE username = '$USERNAME';

5. Insert a new password using the mysql client

Changing a password using the mysql client rather then PHPmyAdmin uses the same queries as mentioned earlier.

Only use this option if you know what you are doing, as you can easily break stuff in your shop.

First, let’s set some variables. Change the values to your preferred values:

export USERNAME="exampleuser"
export PASSWORD="Randompassword123"
export DATABASE="magento_live"
export TABLE_PREFIX="mage_"
export SALT="$( < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; )" ## Or pick your own random password

This uses a random password. Alternatively you can use your own password string as value for $SALT.

Now, run the query to change the password for a user:

In Magento 2 use the following command:

mysql ${DATABASE} -e "UPDATE ${TABLE_PREFIX}admin_user SET password = CONCAT(SHA2('$SALT$PASSWORD', 256), ':$SALT:1') WHERE username = '$USERNAME'"
echo "The password for user $USERNAME is changed to $PASSWORD"

And for Magento 1 use the following snippet:

mysql ${DATABASE} -e "UPDATE ${TABLE_PREFIX}admin_user SET password = CONCAT(MD5('$SALT$PASSWORD'), ':$SALT') WHERE username = '$USERNAME'"
echo "The password for user $USERNAME is changed to $PASSWORD"

These options are really flexible for both store owners and developers. Hope that you will find it useful in your case.

Related posts:

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

How to Reset Admin Password in Magento 1 & 2
5 (100%) 2 vote[s]
2 Comments

Dom

A knowledge craver who always strive to be wiser everyday.

    2 Comments

    1. Ann Rendon
      03/06/2019 at 12:30 am

      Hi Dom, I hired a development company for my Magento Commerce marketplace website in 2014. I had to stop for for family reasons and am now starting again (2018). My old developers won’t work with me again because I stopped. I understand. I now have a new company and am migrating to Magento 2. In the mean time I want to protect what was developed so far and would like to change the password. I see several instructions on how to do it, but I have two problems/questions:
      1-I see just now that the Magento admin panel is assigned or uses an email and fake name from my original developers! What can I do about that?
      2-If I just change the password in admin on the Magento back panel, will I have to go into my web hosting company cpanel and change it there as well? Or will it take care of itself automatically or does one thing have nothing to do with the other?
      3-If I just change the password, and some day I need to use the ‘I forgot my password” feature… the email to change the password will be sent to my old developer company!
      Please help. I am truly lost!
      Ann

    2. Dom
      03/07/2019 at 11:44 am

      Hi Ann,
      1. You can manage Magento admin users by going to System > Permissions > Users and delete or disable the fake accounts.
      2. Your Magento admin password has nothing to do with your hosting.
      3. You can either change email/password of the existing account by doing Option 2 in this post. Or you can go to System > Permissions > Users and create new user for yourself.
      I hope that helps!

    Leave a Comment

    Your email address will not be published. Required fields are marked*