blog-banner

Yet Another Trick To Reset Drupal Admin Password

  • Drupal 6
  • Drupal Planet
  • Drush
  • LINUX SERVER

Earlier I wrote a blog about different ways to reset the admin password, one of those was using Drush. Sometimes you will need only momentary admin access to the site. It happened recently to me when I had to deploy a new feature to a live site but was unaware of the Drupal admin password, however, I had command-line access to the server.

Courtesy: https://drupal.org

Drush is the quickest and most efficient way to reset passwords in such cases. Also, I don't want to reset the password permanently but provisionally, so that I can let the client use his preferred password when I'm done with my work. Here is how I thought it could be done.

First I figured the username and (encrypted) password of the administrator with drush sqlq command

$ drush sqlq "SELECT name, pass FROM users WHERE uid = 1;"
The output returned as below,
name pass
admin d69470a79b09b74f271b11b3c9d89be8

Then with drush upwd I did reset the password,

$ drush upwd admin --password=secretpassword

This gave me access to log in & make the needed changes to the site as a super administrator user. Then I could restore the original password with drush sqlq command.

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

Here d69470a79b09b74f271b11b3c9d89be8 is the encrypted password that I had noted down from the output of the first drush sqlq command. Hope this will help others too and could serve as public documentation for our own team as well :)

Get awesome tech content in your inbox