I tried to reset the admin password via Phpmyadmin in admin_user table but this doesn't seems to work. Also on chrome I am getting "This webpage has a redirect loop" error when loading admin page.

  • 1
    Regarding redirects, make sure that if you have xdebug enabled, then there is xdebug.max_nesting_level=200 in your php.ini. If it is not set, it is possible that you see admin login page (because nesting level is less than default 100 on that page), but when you enter credentials and try to login, dashboard cannot be rendered (nesting level is more than default 100 there). Also make sure to use some virtual host, not "localhost", to avoid issues with cookies. Commented Nov 20, 2015 at 13:17
  • 1
    Dashboard icons / style were not loaded / rendered properly will this be due to xdebug ? Can you share how to setup xdebug on php.ini properly
    – Dev
    Commented Nov 24, 2015 at 13:27
  • Just add xdebug.max_nesting_level=200 to your php.ini config if you have XDebug enabled. Commented Nov 24, 2015 at 13:41
  • github.com/magento/magento2/issues/2175
    – MagenX
    Commented Jan 28, 2016 at 21:23
  • this answer should help magento.stackexchange.com/a/137562/27907 and to generate the hashed password you can use xorbin.com/tools/sha256-hash-calculator
    – w.k
    Commented Sep 22, 2016 at 9:05

12 Answers 12


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"
  • 1
    No other way without CLI? I tried to do that by installing Magerun on my machine (I am newbie to CLI). My command is like below, '<path_to_magento>php bin/magento admin:user:create [--admin-user="dave"] [--admin-password="admin123"] [--admin-email="[email protected]"] [--admin-firstname="dave"] [--admin-lastname="maritus"]'
    – Dev
    Commented Nov 21, 2015 at 4:50
  • 1
    Path to magento should go before "bin/magento", not before php. Also remove square brackets from actual command. Commented Nov 21, 2015 at 7:53
  • Admin user created successfully, I used the details created to login dashboard but it doesn't works, stay on the same login page.
    – Dev
    Commented Nov 21, 2015 at 8:04
  • 4
    only god knows why they put square brackets there...
    – MagenX
    Commented Nov 25, 2015 at 9:26
  • 2
    @MagenX - Square brackets are a conventional way for help messages of a command to tell you that those arguments are optional. It's pretty standard actually.
    – nevvermind
    Commented Jul 13, 2016 at 18:27

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.

  • FYI; the CONCAT and salt is not needed. v. 2.1.7 Commented Nov 7, 2017 at 9:02
  • 2
    Didn't work for Magento 2.3, needs salt, etc.
    – Qtax
    Commented Feb 7, 2019 at 13:50
  • 1
    also, beware "lock_expires" field if you've repeated tried the same wrong password...
    – KolonUK
    Commented Feb 12, 2019 at 12:45

Run the following SQL queries to reset the admin password:

UPDATE admin_user SET password = CONCAT(SHA2(CONCAT(@salt, 'MyNewPassword'), 256), ':', @salt, ':1') WHERE username = 'admin';
  • Was the only way I could get around the password requirements in Magento 2.3, to be able to set a simple admin password for development. n98-magerun2 3.0.4 didn't allow one to avoid the admin password requirements.
    – Qtax
    Commented Feb 7, 2019 at 13:53
  • Worked in Magento 2.2.5, plus setting "lock_expires" to NULL
    – KolonUK
    Commented Feb 12, 2019 at 12:36
  • Worked in Magento 2.3.3, many thanks
    – Badong
    Commented Jun 10, 2020 at 11:56
  • 1
    Still works on 2.3.4. Thank you! Commented Sep 2, 2020 at 18:42

There is a very nice tool out there called N98-Magerun

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           | [email protected]             | active |
| 2  | nextadmin       | [email protected]         | 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.

Password successfully changed

Hope this helps.

  • Couldn't get this to run in my Bitnami test server - SQL was the only way to go for me.
    – KolonUK
    Commented Feb 12, 2019 at 12:36

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
  • This is the only one that worked for me
    – jfoutch
    Commented Sep 1, 2017 at 16:07

I hate remember long string bin/magento ...

Here is solution for anyone like touching:

put this code in pub/index.php


Look at the footer of anypage: enter image description here

Copy that code and go to phpmyadmin:

update admin_user set password = '<code above>' where username='admin';

BTW. This is reset password question if you use admin:user:create it do reset or create but Uhm... Not exactly.

  • 3
    This would not really be safe to do in a publicly open website... You could also download n98-magerun2 and run n98-magerun2.phar dev:console and execute the code there: $di->get("\Magento\Framework\Encryption\Encryptor")->getHash("yourpass"); or just use n98-magerun2.phar admin:user:change-password
    – 7ochem
    Commented May 18, 2017 at 10:54

From Magento 2.3 you can use like following

UPDATE admin_user SET password = CONCAT(SHA2('[salt]NewPassword', 256), ':[salt]:1') WHERE username = 'admin';

And for salt you can get it from the app/etc/env.php

'crypt' => [
    'key' => 'f6fcdcc54d85d8a2f2a87a2ae0a062e9'


If you are emails are working use the forget password option in the admin login screen

enter image description here


Referring to answer of Alex it works with a little modification. You have to navigate into the folder of M2 install, then run the code below:

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

You don't need / before the bin folder, but you need php command before the whole "sentence".

The pass generation worked for me, but the admin page was'nt logged me in:/


Just open your database access and call the following query:

UPDATE admin_user
SET password = CONCAT(SHA2('yournewpassword', 256), ':xxxxxxx:1')
WHERE username = 'yourusername';

Use this command in terminal

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




  1. Here is the solution,

Run the below command:

php bin/magento admin:user:create --admin-user=admin --admin-password=admin123

enter image description here

Enter email, first name, and last name

  1. Reset Magento 2 admin password via Email

2.1 Change Magento 2 admin password using the default recovery system.

2.2 Go to “Admin Panel”

2.3 Click “Forgot Password”

2.4 Enter the Email address and click the “Retrieve password” button.

2.5 Easily set new password with the reset password link received in the Email.This method is useful when you have forgotten the password and want to reset it.

  1. Reset Magento 2 admin password from Account Settings:

3.1 Login to admin panel

3.2 Go to Account Settings as shown in the figure.

3.3 Enter the new password

3.4 Enter it again to confirm the change in password.

3.5 Enter your old password to confirm your identity.

3.6 Save Accounts.

enter image description here

  1. Reset Magento 2 admin password via phpMyAdmin

4.1 Go to phpMyAdmin

4.2 Go to the Database section and search for the admin_user table

enter image description here

4.3 Run the below query as shown in the figure:

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

enter image description here

Thank You!

 1. login to magento 2 admin.
 2. Go to system > All Users.
 3. Select your User
 4. reset password from 'User Info' > 'Account Information'
  • I have edited my question. what If we do when lost a password.
    – Dev
    Commented Nov 20, 2015 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.