I am new to Drupal and this forum.

My problem is that I want to reset my password in Drupal without logging onto my site, but I can only access user/password when I'm logged in.

I've searched a lot and haven't been able to find anything else.

Can anyone help me out?

  • you can use drush for it.
    – Ali Nouman
    Jun 17, 2013 at 13:09
  • First things first - do you use Drush...
    – Chapabu
    Jun 17, 2013 at 13:09
  • Thanks for quick reply.I need to do this in my application.If the user forgot his password,then he reset his password.
    – Pradeep K
    Jun 17, 2013 at 13:18
  • 1
    already there is an option for forgot password in drupal
    – Bala
    Jun 17, 2013 at 13:22

2 Answers 2


If you have drush installed, you can reset your password from the command line using

drush upwd --password="givememypasswordback" admin

For more information you could see the link.


You have several ways to achieve this:

  • Visit yousite.com/user/password then enter your email address and you'll then receive an email with a link to reset your password on your Drupal site.
  • With drush, you have two different ways of doing things:

    $ drush uli --uid=1 --uri=http://yoursite.com

This command will return a URL that will allow you to log in to the site without actually knowing your admin password. Handy.

  • Or as previously suggested by @Nitesh Sethia, using drush, again, to reset your admin password:

    $ drush upwd <username> --password="<newpassword>"
  • Another interesting option is to use the password-hash.sh script that ships with Drupal. At the root of your Drupal codebase, type:

    $ ./scripts/password-hash.sh <newpassword>

This will return a hash with the SHA 512 security. Copy that hash, now log in to your MySQL prompt or via phpMyAdmin (or whatever other GUI of your choice). Select the "users" table and update your admin account by replacing the "pass" hash by your newly generated one. Save. Done. Assuming you'll go for the MySQL prompt and will want to reset UID 1 (superuser) password, run:

    mysql > UPDATE `<yourdatabase>`.`users` SET `pass` = '<yourhash>' WHERE `users`.`uid` = 1;

Last option that I wouldn't recommend is to temporarily hack your index.php file so that, under drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); you add:

    require_once 'includes/password.inc';
    echo user_hash_password('<newpassword>');

Now hit the homepage, copy the hash, and update the "pass" field in the database as explained previously. Revert the changes in index.php. Done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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