TransWikia.com

How to reset lost admin password in Magento 2?

Magento Asked on November 30, 2021

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.

10 Answers

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'
],

OR

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

enter image description here

Answered by Rinto George on November 30, 2021

Just open your database access and call the following query:

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

Answered by zuber bandi on November 30, 2021

Run the following SQL queries to reset the admin password:

SET @salt = MD5(UNIX_TIMESTAMP());
UPDATE admin_user SET password = CONCAT(SHA2(CONCAT(@salt, 'MyNewPassword'), 256), ':', @salt, ':1') WHERE username = 'admin';

Answered by Jun Hsieh on November 30, 2021

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.

Answered by Suresh Chikani on November 30, 2021

I hate remember long string bin/magento ...

Here is solution for anyone like touching:

put this code in pub/index.php

MagentoFrameworkAppObjectManager::getInstance()->get("MagentoFrameworkEncryptionEncryptor")->getHash("yourpass");

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.

Answered by christian Nguyen on November 30, 2021

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.

Username:admin
Password:123456
Password successfully changed

Hope this helps.

Answered by Atish Goswami on November 30, 2021

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:/

Answered by Takács Zsolt on November 30, 2021

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

Answered by Claudiu Creanga on November 30, 2021

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"

Answered by Alex Paliarush on November 30, 2021

 1. login to magento 2 admin.
 2. Go to system > All Users.
 3. Select your User
 4. reset password from 'User Info' > 'Account Information'

Answered by gks on November 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP