Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.

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
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';

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

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


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.