Tech Tips on Computers, Internet, Blogging, Web Development, Social Media, Android and more

Full width home advertisement

Post Page Advertisement [Top]

How to reset dupla 7 admin user password easily
How to reset Drupal admin user password easily?
In this post, we shall see how to reset Drupal admin user password easily from phpMyAdmin. If it is on a production site, we can do "forgot password" to let Drupal send us a password reset link. But on local development server, we might not have a provision to do it. So we may need to do it some other ways. We can reset passwords for user from phpMyAdmin by running some scripts. But as you might already know that passwords in Drupal are hashed. So we need to know the hash code of a password before running such sql command. I have included a SQL code for password reset in Drupal 7 at the end of this post.

This example is on local Drupal 7 running on XAMPP (Windows). In this example, we generate a hash code of a password we desire and replace the existing hash code in PHPMYADMIN with the new one to change the password. Admin can then login in with the new password and may change the password as usually done in Drupal by editing the user.
Watch this short demo video how to  reset Drupal admin user password:


The "password-hash.sh" file located in C:\xampp\htdocs\drupalsite\scripts can be used to generate hashed password. That is what we shall be using to generate hashed password for "admin@123" in this example.

Basic steps involved:
  • Open Windows PowerShell
  • Navigate to C:\xampp\htdocs\drupalsite\
  • From the root of the drupal site in PowerShell, run the command: php scripts/password-hash.sh admin@123, where admin@123 is the password we want to generate the hash code for.

php scripts/password-hash.sh
  • Copy the hashed code generated from PowerShell which is "$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz" for admin@123.
  • Go to localhost/phpmyadmin
  • Open the database respective to the drupal site
  • Open table "users"
  • Against the particular user you want to change the password, double click on the hashed password displayed in phpmyadmin and replace it with the new one generated from PowerShell
change drupal password from phpmyadmin

  • Now login with the new password "admin@123"
  • After login, change the password by clicking on the edit user tab if desired.
Resetting the Drupal user password directly in phpMyAdmin users table:
Now that you know the hash code for admin@123 is "$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz" (without quotes), you can simply replace it in phpMyAdmin if you don't want to go through the Windows PowerShell.

OR

Resetting the Drupal user password using SQL command in phpMyAdmin:
but running this command from phpMyAdmin SQL tab against the drupal database to reset the password.
UPDATE users SET pass ='$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz' WHERE uid = 1;
The above SQL command updates the password to "admin@123" for the user with ID = 1.
Before running the command, kindly note the user ID of the user you want to update from the "users" table of the drupal database from phpMyAdmin and change the ID in the code above accordingly.

If this post was useful to you, kindly like and share. Also do drop me a comment. Thanks.

Note: For demonstration purpose only. Do it at your own discretion on your system.




No comments:

Post a Comment

Bottom Ad [Post Page]