Hey guys,

I'm trying to change my user's password via database because the server is not sending emails, I tried using password('new_password') but it didn't work, was this changed in version 7.43?

Thanks.

Comments

Jaypan’s picture

It uses sha512, and also uses a salt for security sake. the actual function used for the hashing is: https://api.drupal.org/api/drupal/includes!password.inc/function/_passwo...

Suffice to say directly changing the user's password in the database is not likely to work so well. See if you can find the mail that failed to send in your server logs, and get the link to reset their password from there. If that doesn't exist, you can also use Drush to reset passwords.

jfha73’s picture

Thanks, I'm back on track again.

arulraj’s picture

Create password-change.php file equivalent to site folder and add below code on it.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require './includes/password.inc';
print user_hash_password('yourpassword');

if execute this file from browser, will get encrypted password for your plain text, then execute below query.

Example:
"UPDATE user SET pass='$S$CpiOFu0x5iXapILxJCsVJGbh2fHB11HLGjBDp2XbfofmpiqOd1xj' where uid='1';"