How to Reset the Magento 2 Admin Password from the Database

If you found this post helpful, kindly share it and show your support :)

The Magento 2 Admin user password cannot be changed via a command, but it can be changed through the database by following the steps.

Step 1: Connect to MySQL database

By using the mysql command, you can connect to a MySQL database.

mysql -u DB_username -h DB_host DB_name -p

Replace DB_username, DB_host, and DB_name with your database username, database host, and database name.

Step 2: List the Magento users

You can view a list of the Magento users created within the database by using the command listed below.

select * from admin_user;

You can run the following database query once you’ve located the Magento admin user whose password you want to update.

UPDATE admin_user SET `password` = CONCAT(SHA2(CONCAT(@salt, 'new_password'), 256), ':', @salt, ':1') WHERE username = 'admin_user';

Replace new_password and admin_user with your password and Magento username.

That’s it 🙂


Mohammed Noufal

I'm Mohammed Noufal, working as Server Admin for the last 10 years.  In my day-to-day life, l had to face different problems related to Web-hosting. On my website, you can find solutions for different Web-hosting-related problems. Sometimes, I spent hours searching/googling to find a solution. This inspired me to start a website that gives solutions to different Webhosting problems. This website includes basic Linux and windows commands, and different control panels like cPanel, Plesk, DirectAdmin, Webmin & so on. You can find solutions and or suggestions for different Web-hosting related problems from here. Hence I would like to say Errorlogz is your server protector.  I will be glad if Logdetect can help any one of the Server admins to find a solution to his problem.

You may also like...

Leave a Reply

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