Reset admin password in drupal 7

 D7 users table does not store a simple md5 hex hash. Drupal 7 stores a salted sha512 hash.

You can always use the user_hash_password('mypassword') function (located in includes/password.inc) to make yourself a new one, then paste it into the database.

In your index, you can write this code. Execute your web page. .

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

Add it after drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require('includes/password.inc');
echo user_hash_password('newpassword'); 
die();
menu_execute_active_handler();



Then visit your site, you'll get the hashed "mynewpassword", copy it, open index.php, revert your changes, update the database with the hash you got.

No comments:

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...