Magento 2 different ways to reset admin user password

In this post, we will learn how to change the magento admin user password from database or FTP or cmd. This will help you in case you are not able to recover it using Forgot Password option. (Mostly happen when working locally). Consider that you have server access to magento i.e database or ftp access.

Reset magento 2 admin password With Database

The easiest way to change magento admin password is using database. Open your database in phpmyadmin, and execute the below query:-

UPDATE admin_user SET password = CONCAT(SHA2('xxxxxxxxpassword', 256), ':xxxxxxxx:1') WHERE username = 'arushi' 

Replace password with your password. Each xxxxxxxx sequence should be replaced with any random characters.

Reset magento 2 admin password using Command line

php bin/magento admin:user:create --admin-user mys_username --admin-password p@123 --admin-email --admin-firstname john --admin-lastname Hu

Username and email should match with database to update all details. Replace p@123 with your password.

Reset magento 2 admin password using FTP

Through FTP open the class Magento\User\Model\User located at vendor\magento\module-user\Model\User.php
Next find the verifyIdentity() function around line no: 561. Inside the verifyIdentity function, this code is written

return $result;

You need to replace the line with

return true; 

Thus we are login without using any password and now you can change the password from admin panel.

Leave a Comment.