Jojodae Ganesh Sivaji
January 16, 2013
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;"
name passadmin 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 :)
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!