Yet another trick to reset Drupal admin password
Earlier I wrote a blog about different ways to reset admin password, one of those was using Drush. Sometimes you will need only momentary admin access to site. It happened recently to me when I had to deploy a new feature to live site but unaware of Drupal admin password, however I had command line access to server.
Drush is the most quick and efficient way to reset password 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;"
name passadmin d69470a79b09b74f271b11b3c9d89be8
Then with drush upwd I did reset the password,
$ drush upwd admin --password=secretpassword
This gave me access to login & make the needed changes to site as 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 encrypted password that I had noted down from the output of first
drush sqlq command. Hope this will help others too, and could serve as a public documentation to our own team as well :)