Creating a password for a user in Drupal 7
Ok, so you've exported your database from one system to another, but your login isn't working. Why? I'm not really sure but it seems the hash relies on the hostname in Drupal 7? Haven't really dug in yet to figure out the specifics. So with Drupal 6 you would just md5 a password and then stick it in the database. But oh no, we can't md5 anymore in D7, so what do we do.
Well a bit of grepping found scripts/password-hash.sh shell script in our Drupal install. So, if you need to create a new password for you user, just run (from your Drupal directory):
You have to run this from your Drupal directory, if you run it from the scripts directory itself (for example, ./password-hash.sh yourpassword) then it will fail
where your password is the desired password for the user. Then hop over into MySQL and update the user with the new password hash, for example:
"UPDATE user SET pass='$S$CpiOFu0x5iXapILxJCsVJGbh2fHB11HLGjBDp2XbfofmpiqOd1xj' where uid='1';"
And yay, now we can login.
Side note: Wanted to update this to say, in some environments, you might get the error: "-bash: ./scripts/password-hash.sh: /usr/bin/php: bad interpreter: No such file or directory"
One can get around this by creating a custom php script and using "drush php-script" to run it. So create test.php and in it put the code:
Then from command line in your Drupal root directory run:
drush php-script test.php
Obviously, that is a less than preferable way to do things, but it works in a jam.