Drupal Tutorials and Blog Posts

Reset a Lost Drupal Administrator Password

February 2, 2012 | Written by Steve Burge

The User 1 account on a Drupal site has special status. This account has life and death rights on your Drupal installation and needs to be protected at all costs. If you've lost access to this account, then it is important to regain that access.

Your first step should be to try and reset your password by adding this to your site's URL: /user/password/. If that doesn't work or if you don't know the email for the account, then you can manually reset your password in the database. Here's how to do it:

tutuploadsmedia_1328733261326.png

Access your database. In thix example we're gong to use phpMyAdmin. If you're using commercial hosting then phpMyAdmin will be access from your hosting control panel. On XAMMP and other local apache installations also have methods for getting to phpMyAdmin.

Step 3. Choose the correct database

tutuploadsStep_3._Choose_the_correct_data_base.png

If you have more than one database, be sure to select the correct one to work with from the left hand column.

Step 4. Choose the correct table and browse to the entry

tutuploadsStep_4._Choose_the_correct_table_and_browse_to_the_entry.png

Scroll down and click on the users table. Choose the Browse tab at the top of the right hand panel.

Step 5. Open the entry to make changes

tutuploadsStep_5._Open_the_entry_to_make_changes.png

Scroll down to see your user entries. The headers may be kind of large and it looks like empty tables. The users are listed below the headers.

Find user 1 - the user number is next to the user name. Drupal ALWAYS makes user 1 the administrator. Don't ever delete user 1.

Click the pencil-edit icon.

Step 6. Choose MD5 and type in a new password

tutuploadsStep_6._Choose_MD5_and_type_in_a_new_password.png

Select MD5 from the dropdown menu.

Type in a brand new password.

If you're done, you can scroll to the bottom of the page and click "Go" and your password will now be changed.

tutuploadsmedia_1328734185604.png

After you click "Go" you will see that the password has been encrypted. It has been changed and you can now log in with your new password.

Step 6. Changing the user email

tutuploadsStep_6._Changing_the_user_email.png

To change the email, type a new email in the mail field. There is no need to make a selection from the drop down box if you are changing the email.

Click Go to save your changes.

You can do this at the same time as resetting the password, or in a separate step.

If You're a Database Pro ...

To directly reset your password, log into phpMyAdmin and execute the following mySQL statement:

UPDATE users SET pass = md5('newpassword') WHERE uid = 1;

Enter your new password in the md5 function - it will automatically be converted via a one-way hash (this is why we can't retrieve your old password - the decryption is a one-way process). Note that for earlier versions of Drupal you may need to use SET password, instead of SET pass.

This will effectively reset the Drupal admin password for user 1. Note that you can use this to reset the password of any user, although this is typically unnecessary as you should be able to simply log in as admin user (user 1), under which you have the ability to reset any user's password.

 


 

Add comment