How to Reset the Magento 2 Admin Password from the Database
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.
SET @salt = MD5(UNIX_TIMESTAMP());
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 🙂