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.
12 Answers
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"
-
1No 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"]'– DevCommented Nov 21, 2015 at 4:50
-
1Path 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.– DevCommented Nov 21, 2015 at 8:04
-
4
-
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. 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.
-
-
2
-
1also, beware "lock_expires" field if you've repeated tried the same wrong password...– KolonUKCommented Feb 12, 2019 at 12:45
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';
-
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.– QtaxCommented Feb 7, 2019 at 13:53 -
Worked in Magento 2.2.5, plus setting "lock_expires" to NULL– KolonUKCommented Feb 12, 2019 at 12:36
-
-
1
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.
-
Couldn't get this to run in my Bitnami test server - SQL was the only way to go for me.– KolonUKCommented 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
I hate remember long string bin/magento ...
Here is solution for anyone like touching:
put this code in pub/index.php
\Magento\Framework\App\ObjectManager::getInstance()->get("\Magento\Framework\Encryption\Encryptor")->getHash("yourpass");
Look at the footer of anypage:
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.
-
3This 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 usen98-magerun2.phar admin:user:change-password
– 7ochemCommented 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'
],
OR
If you are emails are working use the forget password option in the admin login screen
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"
@Dev
Hey,
- Here is the solution,
Run the below command:
php bin/magento admin:user:create --admin-user=admin --admin-password=admin123
Enter email, first name, and last name
- 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.
- 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.
- 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
4.3 Run the below query as shown in the figure:
UPDATE admin_user SET password = SHA2('NewPassword', 256) WHERE username='admin';
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.– DevCommented Nov 20, 2015 at 12:37
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.xdebug.max_nesting_level=200
to your php.ini config if you have XDebug enabled.