For testing purposes I like to reset all user passwords to 123.

Is this possible in Drush or SQL? I guess the query will be someting like this but cannot find the exact yourhash:

UPDATE `<mydatabase>`.`users` SET `pass` = '<yourhash>' ;

Can I run the final query with drush?


Yes, you can do this using Drush, with following steps (e.g.):

1.Generate a password hash using following command:

$ cd [/var/www/html/drupal7]
$ php scripts/password-hash.sh '123'

2.Now run following drush command:

$ drush sql-cli
mysql > UPDATE users SET `pass` = 'pasted_big_hash_from_above' WHERE uid > 1;

Update pasted_big_hash_from_above with password hash generated using php command in step #1.



Query can be done in Drush with:

drush sql-query UPDATE `users` SET `pass` = '$S$DM7xrCBIKOrShBhgb1eUkpPlnnAq36QKIlMfdkKhvaTS2iv0PuJ3'
  • This hash corresponds to 123 for the specific site only. Jul 13 '18 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.