Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am an apprentice and am using Drupal for work it installed Drupal on to my machine and got it all up and running then I accidently logged out and now I can't log back in. I have tried to send a password reset but Drupal doesn't like the email address or username that I put in. I'm relatively new to this so I ask to keep it simple! :) What can I do?? Thanks in advance

share|improve this question

3 Answers 3

This is easiest using Drush http://drupal.org/project/drush

drush user-password username --password="new_password"
share|improve this answer

An alternate method without using Drush. Open your preferred mysql client(PhpMyAdmin/Adminer/MySQL GUI) and run these queries. Substitute letters in BLOCKS with actual values.

use `MY_DATABASE_NAME`;
update `users` set pass = md5('MY_NEW_PASSWORD_WHICH_I_CANNOT_FORGET_AGAIN') where uid = 1

If you are not sure of the username that you used you can run this query to retrieve it.

select name from users where uid = 1;
share|improve this answer
1  
Bear in mind that will only work for D6, D7's password hashing is (thankfully) a bit more sophisticated than it used to be –  Clive Nov 26 '12 at 17:25
    
THought I saw a 6 tag somewhere ! Confused it with Rep, will update it. –  GoodSp33d Nov 26 '12 at 17:34

As you installed Drupal on your computer, you can follow this method to change the password for the account with which you are trying to log in. Create a changepass.php file in the same directory containing the index.php file used from Drupal. The following is its content.

// Drupal 7.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if ($account = user_load($uid)) {
  $edit['pass'] = $new_password;
  user_save($account, $edit);
}
// Drupal 6.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if ($account = user_load($uid)) {
  $edit['pass'] = $new_password;
  user_save($account, $edit);
}

Replace $uid with the user ID (1 in the case of the first user created when Drupal is installed), and $new_password with the new password.
Connect the browser to http://localhost/changepass.php, and the password will be updated with the one you choose. (Replace localhost with what is appropriate to connect to the web server on your computer, if localhost doesn't work.)

This method saves the password using the correct value, and the correct hashing which (on Drupal 7) can be changed by a module.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.