For an X or Y reason, the process to reset a Magento 2 Admin password may not work. In such cases, you have many other alternatives that you can try. In today's article, we will discuss four different approaches to reset a Magento 2 Admin password. Whether you are developers, or a store, you don't have to remain out of your Magento dashboard. At the end of the post, you will understand how to use the standard process (email reset link) or the database reset.
Where Would you need this article?
There are many scenarios in which the current article may be useful. And below are some of them:
- You don't know how to reset your password and want to understand how to do it. It is particularly useful for novice store owners that just get started with Magento 2. Hence, following the steps will give you a better idea of what to do if you don't remember your password.
- Your email system is not working, and you don't receive the reset link. It may happen that the email systems of your server won't work correctly, and hence, when you try to reset your password, you don't receive any email. In such cases, use the database approach will help.
- Your developer left and locked you out of your website. And you need to access your dashboard and take over your website.
In any case, you can try any of the suggestions below to access your dashboard.
Differents approach to reset a Magento 2 Admin password.
You may have more than four approaches, but trying one of the suggestions below may help.
Use another Admin dashboard to reset a password. (1)
If your Magento 2 website has more than one administrator, you may use the other admin password to reset your password. In such a case, you can ask the second administrator to log in and help you with the process. Here are the steps to follow.
- Log in to your Magento dashboard
- Go under the tab System -> Permissions -> All Users
- From the list of users, select the user you will want to reset the password
- Then, add the new password and confirm the password
- At the bottom of the form, enter your password
- And then click on "Save User."
Use the dashboard login page to reset a password. (2)
Another way to reset a Magento 2 Admin password is to go on the admin login page. In this case, you can follow the steps below.
- Go to your Dashboard login page and click on the link "Forgot Your Password?"
- And a form will appear with a field to add the email address.
- Enter your email address and click on "Retrieve Password."
- Magento will send you a reset link to your email address.
- In some cases, Magento does not send the reset link due to the email system issue. If that is the case for you, you can try the other methods to access your dashboard.
- If you don't know your dashboard URL, you can check your env.php file app/etc/
'frontName' => 'adminccldd',
Where 'adminccldd' is the slug to your dashboard, you will then have something like "https://yourURL.com/adminccldd."
Reset a Magento 2 Admin password directly from the database (3)
If you are not able to get the reset link in your email or you don't have more than two administrators on your site, you can do it directly from your database. Here is how you can do that.
Step 1 - Get the cryptographic key.
- Login to Magento 2 installation folder,
- and go to app/etc/env.php
- Copy the cryptographic key under "crypt.'
The key look like this:
'key' => 'd10075ee37ff3f6dddssdlldac352773a029',
Step 2 - Run MySQL query in PHPMyAdmin
SET password = CONCAT(SHA2('keyNewPassword', 256), ':key:1')
WHERE username = 'myusername';
- Replace prefix by the prefix of your Magento 2 database tables. For example, if your prefix is mag2, you will have mag2,_admin_user.
- Change "key" by your cryptographic key. If we assume that your cryptographic key is d10075ee37ff3f6dddssdlldac352773a029, then you will run your MySQL query with and have something like in the example below.
- And finally, myusername is your username.
SET password = CONCAT(SHA2('d10075ee37ff3f6dddssdlldac352773a029NewPassword', 256), ':d10075ee37ff3f6dddssdlldac352773a029:1')
WHERE username = 'myusername';
Use the command-line interface (4)
In most cases, the three methods above would work. But, it may happen that you don't have a second administrator, the email system is not working, and you don't have access to the PhpMyAdmin. If that is the case, the Command line will help. In this case, the approach will be to create a new administrator login that you can use to access the dashboard. Once you are into your dashboard, you can either reset your password or delete the previous user. Here are the steps you need to follow:
- Open your command line,
- And navigate to the leading directory of your Magento installation
- type the following command
php bin/magento -h
You will have something like this:
admin:user:create Creates an administrator
admin:user:unlock Unlock Admin Account
php bin/magento admin:user:create
And it will ask you to provide the username, password, email, last name and first name.After providing all the information, flush the cache.
php bin/magento cache:flush
If you followed all the steps, you would be able to login to your Magento 2 dashboard as an administrator.
The process to reset a Magento 2 Admin password is not always straightforward. However, if you can one of the methods suggested, you can try another.Thanks for taking the time to read our article, if you like the article, you may also be interested in "6 different approaches to reset a WordPress password"Contact us
if you have any questions. And send us a message to get your free quote for any Magento development
or website development services.