How to change or reset a password with the terminal in Drupal 8/9

Submitted by admin-matapedia on

You can easily reset a user password with Drush utility.

Go in your Drupal installation root and check if Drush is installed.

$ cd <app root>
$ vendor/bin/drush status

Drupal version     : 9.3.2                                                                               
Site URI               : http://default                                                                      
DB driver              : mysql                                                                               
DB hostname          : localhost                                                                           
DB port                : 3306

If you have this result, you have to install drush with the following command

$ composer require drush/drush    

Set the password for the user somedrupaluser with arguments :
name : The name of the account to modify.
password : The new password for the account.

vendor/bin/drush user:password somedrupaluser somedrupalpassword

Enjoy!

Tags
Categories