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

as

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

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

define('DRUPAL_ROOT', getcwd());

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

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

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

echo user_hash_password($pwd);
?>



source : http://drupal.org/node/865818

No comments:

Post a Comment