Saturday 17 December 2011

How to reset Drupal admin password?

There's nothing more frustrating than missing/lost your drupal admin password and you are locked in a situation where you don’t know what to do next. I have been in such situation and found a solution as well as wanted to share with you all.
The first thing to try is to click on the lost password link, and have the password emailed to you. There are, however, a couple scenarios where this will fail to work:
1. This won't work if you're unable to access the retrieve password page.
2. This won't work if you've stored an old, no longer in use email address for the admin user (user 1).
Resetting your Drupal admin password using phpMyAdmin
This is the best php tip I have found for reseting drupal administrator's password. You will need access to phpMyAdmin or some way to manage your database.
Follow the below steps to get your drupal admin password reset quickly:
1. Login to cPanel -> Databases box -> phpMyAdmin;
2. Select the Druapl database folder from the left navigation bar. The page will refresh and and the Drupal database’s tables will be displayed on it. (in case you don’t know the DB name, you can find it by looking into setting.php file)
3. Click on the SQL tab. In the text field write the following SQL query:
update users set pass=md5(‘NEWPASS’) where uid = 1;
You can replace “NEWPASS” with your new Drupal administrative password.
Restting admin password using Drush
If you are using Drush (a command line shell and scripting interface for Drupal), you can run the following line
drush php-eval 'db_query("UPDATE `users` SET `pass` = MD5(\"NEWPASS\") WHERE `uid` =1;");'
Note: Don’t forget to add table prefixes if your site uses them.
You can also find documentation  at Drupal.org for resetting admin password for Drupal 6 and Drupal 7

No comments:

Post a Comment