When developing a Drupal site, sometimes you have the need to reset a password - either for yourself or another user. Often, when working with a copy of live data, I want to be able to login as another user who is already in the system. Rather than asking them for their password, I use this method to change it.
While Drupal's built-in "reset password" functionality or user editing capabilities work great, if you're like me and tend to work with your database editor open, there's a quick-and-dirty way to quickly change a user's password.
Using phpMyAdmin, navigate to Drupal's "user" table and navigate your way to the user record you're interested in. Click to edit the record then type in the new password in the password field.
Here's where the magic comes in - before you hit "submit", change the "function" select box to "MD5" - this will encode the plaintext password using the MD5 hash - the same one Drupal uses. If you don't perform this step, Drupal will be trying to compare a plaintext password against a hashed password - they'll never match and the password won't work.
Comments
Password maintenance
Great tip.
Once you get used to working with the database,
it's alot easier to do user & site maintenance.
doesn't work!
doesn't work!
Drupal 7 has added a "salt"
Drupal 7 has added a "salt" for password hashes. You would need to add the salt to the password as well in order to recreate the hash.
It's just not that simple any longer:
http://api.drupal.org/api/drupal/includes--password.inc/7/source
Drupal Handbook
Please see this tutorial in the handbook:
http://drupal.org/node/1023428
Another tutorial that will waste people's time
Time to remove this. It's old hat and incorrect for any recent version of Drupal
Drupal 7
For Drupal 7, execute this command from the root of your Drupal directory:
./scripts/password-hash.sh mynewpassword
... where "mynewpassword" is the new password you choose. Then you have a slated hash to put into the database either via command line or PHPmyAdmin