Saturday, April 16, 2011

Change Admin Password in drupal 7

last week i installed drupal 7 but i forgot the admin password and i was looking to change this in database as there was no email configuration on my local pc . after some R&D i come to know this method

put the following code in drupal root directory and then change the $pwd value to your desired password and the visit this file in browser and you will a hash password and update it direclty in databse


UPDATE users SET pass = '[hash]' WHERE uid = 1;

in my case uid was 1 .
$pwd = 'password';

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/';
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/');


header("Content-Type: text/plain; charset=utf-8");

echo user_hash_password($pwd);

source :

No comments:

Post a Comment