Resetting the Drupal administrator password
There are several ways you can reset your Drupal administrator password if you are locked out and can't use email recovery. This article shows you how.
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:
-
Use your web browser to go to the Drupal login page.
-
Click Request new password.
-
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). -
Click E-mail new password. Drupal sends a message to the e-mail address associated with the administrator account.
-
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:
-
Log in to your account using SSH.
-
At the command prompt, use the cd command to change to the directory where Drupal is installed. For example, type
cd ~/public_html
. -
Type the following command. Replace NewPassword with the new password that you want to use:
drush upwd --password="NewPassword" admin
Note
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.
-
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:
-
Log in to cPanel.
Note
If you do not know how to log in to your cPanel account, please see this article.
-
In the Databases section of the cPanel home screen, click phpMyAdmin.
-
In the left-hand pane of phpMyAdmin, click the Drupal database. A list of tables in the database appears.
Tip
Typically, the Drupal database is username_drupXXX , where username represents your cPanel username, and XXX is a three-digit number.
-
On the top menu bar, click SQL.
-
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;
Note
-
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;
-
-
Click Go. phpMyAdmin updates the database with the new password.
-
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:
-
Log in to your account using SSH.
-
At the command prompt, use the cd command to change to the directory where Drupal is installed. For example, type
cd ~/public_html
. -
Type the following command, replacing NewPassword with the new password that you want to use:
php ./scripts/password-hash.sh "NewPassword"
-
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.
-
Log in to cPanel.
Note
If you do not know how to log in to your cPanel account, please see this article.
-
In the Databases section of the cPanel home screen, click phpMyAdmin.
-
In the left-hand pane of phpMyAdmin, click the Drupal database. A list of tables in the database appears.
Tip
Typically, the Drupal database is username_drupXXX , where username represents your cPanel username, and XXX is a three-digit number.
-
On the top menu bar, click SQL.
-
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;
Note
-
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;
-
-
Click Go. phpMyAdmin updates the database with the new password.
-
You should now be able to log in to Drupal as the administrator using the new password.
Related Articles
Updated 1 day ago