Resetting or updating passwords for Drupal users in command line

The


drush user-login username

command or it's alias


drush uli username

will display a one-time login URL to login the specified account. The output is a URL like:


http:///user/reset/1/1358351267/WvqBsED_WKGeThnoY67SCRddVfpGymDaA1w1GP7ZTtP

After logging in using this URL, the user it NOT required to change the password.

To generate one time login for user #1 fire up just


drush uli

Running


drush sqlq "SELECT name, pass FROM users WHERE uid = 1;"

command will output something like:


name pass
Developer $S$DW9QZxPm5DWDfYxNDEiKfM08XPClb1tjcMo8bu01m6SvZH8FmzWs

Then you can update a password for this user with:


drush upwd Developer --password=secretpassword

If you want to revert to the old password then run:


drush sqlq "update users set pass='$S$DW9QZxPm5DWDfYxNDEiKfM08XPClb1tjcMo8bu01m6SvZH8FmzWs' where uid = 1;"

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.