Drupal: Reset admin password

This CodeLet will create hash for your admin password. You can provide the string for password and the CodeLet will generate the hash. You can then copy this hash and add in password field in the users table. The code has to be put in index.php of your Drupal installation and the order of the code is important.

CodeLet: 

define('DRUPAL_ROOT', getcwd());
require DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

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

If you failed to login after certain tries, you will require to flush the 'flood' table

By DrupalD on Fri, 03/05/2013 - 9:31am

Comments

#1
DrupalD's picture

Needless to mention, this trick works for all the users. If you do not have drush available on your machine/hosting plan, you can simply use this trick to reset password quickly, without requesting an email.

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback