Flipkart

Monday, June 20, 2011

Reset admin(uid = 1) password in drupal 7

When the password for the user to Drupal (the administrator) is lost and the e-mail notification does not work, you can set the password via an SQL query.

But you must first generate a password hash that apply to your site.

Run the following commands from the command line, in the Drupal root directory:
For Linux:
./scripts/password-hash.sh newpassword

For Windows:
php .\scripts\password-hash.sh newpassword 

Then it will generate the Hash Password which somethink like
$S$CTo9G7Lx28rzCfpn4WB2hUlknDKv6QTqHaf82WHTsTHiod

Then execute the following query on the Drupal database:
UPDATE users SET pass ='thepasswordhash' WHERE uid = 1; 

OR you can use below code to get the Password:

require_once 'includes/password.inc';
echo user_hash_password('newpassword'); 
die();

Add above lines in index.php below this
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


And refresh it .

No comments:

Post a Comment