How to reset the Drupal administrator password

This article describes how to reset the Drupal administrator password.

Normally if you forget your password, you can use the Drupal password recovery feature to reset the password by e-mail. However, if this option is unavailable (for example, if e-mail on your site is not working correctly), there are other ways to reset the password.

Method #1: E-mail

The quickest and easiest way to reset an administrator's password is to request a new one through e-mail. To do this, follow these steps:

  1. Use your web browser to go to the Drupal login page.
  2. Click Request new password.
  3. In the Username or e-mail address text box, type the e-mail address associated with the account, or type admin (if you have an administrator account with a different username, type that name instead).
  4. Click E-mail new password. Drupal sends a message to the e-mail address associated with the administrator account.
  5. In the message, click the link to reset the administrator password.

Method #2: Drush

You can use the Drush command line tool to reset the administrator password (or the password of any other user). To do this, follow these steps:

  1. Log in to your account using SSH.
  2. At the command prompt, use the cd command to change to the directory where Drupal is installed. For example, type cd ~/public_html.
  3. Type the following command. Replace NewPassword with the new password that you want to use:
    drush upwd --password="NewPassword" admin
    This command assumes that you want to change the password for the admin user account. To change the password for a different account, type its username instead of admin.
  4. You should now be able to log in to Drupal as the administrator using the new password.

Method #3: phpMyAdmin

You can also modify the administrator password directly in the database using phpMyAdmin. The steps to do this depend on the version of Drupal you are running.

Drupal 6

To manually reset the administrator password for Drupal 6, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. In the Databases section of the cPanel home screen, click phpMyAdmin.
  3. In the left-hand pane of phpMyAdmin, click the Drupal database. A list of tables in the database appears.
    Typically, the Drupal database is username_drupXXX, where username represents your cPanel username, and XXX is a three-digit number.
  4. On the top menu bar, click SQL.
  5. Copy and paste the following statement into the SQL query text box. Replace NewPassword with the new password:
    UPDATE users SET pass = MD5( 'NewPassword' ) WHERE uid = 1;
    • This command assumes that you want to change the password for the admin user account. To change the password for another account, change the uid field to the correct value. To determine an account's associated uid value, look at the users table data.
    • If your Drupal installation uses table prefixes, make sure you add it to the users table. For example, if your Drupal table prefix is dr_, you would type the following command instead:
      UPDATE dr_users SET pass = MD5( 'NewPassword' ) WHERE uid = 1;
  6. Click Go. phpMyAdmin updates the database with the new password.
  7. You should now be able to log in to Drupal as the administrator using the new password.
Drupal 7

To manually reset the administrator password for Drupal 7, you must first generate a password hash. Then you can use phpMyAdmin to update the Drupal database with the hashed password. To do this, follow these steps:

  1. Log in to your account using SSH.
  2. At the command prompt, use the cd command to change to the directory where Drupal is installed. For example, type cd ~/public_html.
  3. Type the following command, replacing NewPassword with the new password that you want to use:
    php ./scripts/password-hash.sh "NewPassword"
    
  4. The script displays the password you entered and its corresponding hash value after hash:. Copy the entire alphanumeric hash string. You will need this value when you update the database in phpMyAdmin.
  5. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  6. In the Databases section of the cPanel home screen, click phpMyAdmin.
  7. In the left-hand pane of phpMyAdmin, click the Drupal database. A list of tables in the database appears.

    Typically, the Drupal database is username_drupXXX, where username represents your cPanel username, and XXX is a three-digit number.
  8. On the top menu bar, click SQL.
  9. Copy and paste the following statement into the SQL query text box. Replace HashValue with the hash string you copied in step 4:

    UPDATE users SET pass = 'HashValue' WHERE uid = 1;
    • This command assumes that you want to change the password for the admin user account. To change the password for another account, change the uid field to the correct value. To determine an account's associated uid value, look at the users table data.
    • If your Drupal installation uses table prefixes, make sure you add it to the users table. For example, if your Drupal table prefix is dr_, you would type the following command instead:
      UPDATE dr_users SET pass = 'HashValue' WHERE uid = 1;
  10. Click Go. phpMyAdmin updates the database with the new password.
  11. You should now be able to log in to Drupal as the administrator using the new password.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.