Submitted by admin on Mon, 09/09/2019 - 12:47

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. This tutorial will show you how to do it.

Click here for this tutorial in Drupal 7.

Step 1. Access your database

Image removed.
  • Access your database. In this example we're going to use phpMyAdmin. If you're using commercial hosting then phpMyAdmin will be accessible from your hosting control panel. On XAMMP and other local apache installations you also have methods for getting to phpMyAdmin.
Image removed.
  • If you have more than one database, be sure to select the correct one to work with from the left hand column.

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

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

Step 3. Open the entry to make changes

Image removed.
  • 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. Click here to find out more about User 1.
  • Click the pencil-edit icon.

Step 4. Choose MD5 and type in a new password

Image removed.
  • 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.
Image removed.
  • 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 5. Changing the user email

Image removed.
  • 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.

Note: This method only works with D6. D7 uses a different encryption method.

Solutions Img