Resetting admin password in Drupal in localhost
Drupal-7 store one way encrypted password in database and can not be recover if we forgot. Below is the code we can use to reset your password of your choice. (You can reset it using sending email also..here I am showing how to reset it using backend)
Just create a file “new_password.php” (or with any other name) inside your drupal folder and access it using browser. It will generate one way encrypted hash password for you.
<?php define("DRUPAL_ROOT", getcwd()); require_once DRUPAL_ROOT . "/includes/bootstrap.inc"; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); require_once "includes/password.inc"; echo user_hash_password("123456"); die(); menu_execute_active_handler(); ?>
When you run this code in browser it will show you hash password like
UPDATE users SET pass = '$S$D95YW4EejaUDPq5nZ7Z2Ljx1Ud4wlN1iTMQdAKton70JcQpCZmrG' WHERE uid = 1;
Now you can access drupal using username as “admin” and password as “123456”. Make sure you update password after login to the admin.
The Above code is as per drupal version: 7