How to Reset the Admin password in Drupal

Have You Lost your Drupal admin password ?

I find it frustrating to update or reconfigure a Drupal site ending up being unable to login (usually due to my own actions) - and having lost or forgotten the admin password. This essentially locks me out of my site entirely. There might be hope.

The first stop is, of cause, to click on the lost password link, and have the password emailed. This works, provided that You can access the retrieve password page, and that You have remembered to keep the e-mail address for the admin user up to date.

Well since You are reading this, one of these conditions fail. The good news is that two more options remains, provided You have access to the database password: reset or retrieve the admin password.

Reset the admin password.

If You are using a mysql back end to Drupal, log into the Drupal database using:

mysql -u root -p drupaldbname

and execute:

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

The user having uid=1 is the special admin user.

Retrieve the lost admin password.

If You do have access to the retrieve password page, you can modify the e-mail address directly in the database. You still need to be able to log on to the mysql database, and You need to be able to access to the retrieve password page - so I personally find resetting the admin password easier.

Anyway here it goes, log into the Drupal database as above, and execute:

UPDATE users SET mail = "
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 " WHERE name = "peter";

Please use an  e-mail address where You can recieve mail, and leave the IANA serves in peace !

Enjoy.