How to reset admin password in Drupal 7
In order to reset Drupal 7 administrator password you will need to follow the steps described below:
- Make a copy of index.php file in your Drupal directory and add following code after the line “drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);”:
- See the image below:
- Open the copy of the index.php file with the newly added code. You will notice a newly generated hash key which you will need to use in the database, see the image below:
- Save the generated code and access your database. Using shell you can change the password by using following sql query:
UPDATE `your_drupal_database`.`drup_users` SET `pass` = 'hash_code_you_generated' WHERE `drup_users`.`uid` =1;
If you want to change the password over the phpMyAdmin you will need to find table called “drup_users” and insert new hash code into the field “pass” for your administrator user. See the image below:
- Save the entered data to change your password and remove the copy of index file to finish the setup and use your new password to login to your administration panel.
1 2 3
require_once 'includes/password.inc'; echo user_hash_password('your_new_password'); die();
The generated code is a hash code of a password “your_new_password“.