Reset Password in the Database

April 22, 2015

Have you forgotten the admin password for a site that you build a long time ago? You have tried to request a single login via email and even Drush, nothing works.

If you have access to the database there is a way to change the password in the database directly. Here are the steps:

Fire up phpMyAdmin, find the users table in the database and click on Browse.

You’ll now see something like this:

Click on the Edit link for uid1 and you’ll see:

The row pass holds the password. However, we can not just input a new password. Drupal7 passwords use a secure hash algorithm called SHA512 with a salt. It employs a security technique called key stretching,, which makes it more difficult to crack the password.

Instead we need to generate a hash from our new password. Fortunately, the Drupal installation includes a utility function that can help us.

Start terminal, navigate to your site root and execute this command:

./scripts/ [your new password in clear test]

The script will output the hash, which looks something like this:


Copy this string into the phpMyAdmin pass input field and click Go.

Now you can login with you new password.

There is a very useful discussion about this subject on