Resetting Drupal Passwords in Drupal 7 with Drush

Sometimes, whether in testing or other situations, you need to reset a password (often the admin password) for a Drupal site.

Edit: The shortest answer is that two wonderful options are built into drush!

# Get an admin login link
drush uli

# Set the password for any user
drush upwd admin --password="newpassword"

The latest versions of drush have drush uli which just gives you a one-time login link for admin.

$ drush uli

Unfortunately it doesn’t get the hostname right in most cases (probably there’s no way to know it if base_url is not set) so you have to change "default" correct hostname.

So in the case above, I would paste the link into a browser and then change it to

There I have a one-time login link to user 1 on the site. Works flawlessly.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Up ↑

%d bloggers like this: