Home
/
Other Applications
/
How to reset my Drupal admin password?

How to reset my Drupal admin password?

Table of Contents

Drupal 8

Use Drush to change the password on your Drupal 8.  Execute the following command:

drush8 user-password someuser --password="enter-new-password"

Change someuser with your actual username and the new password.

Drupal 7

To change the admin password of your Drupal website, create a new file named user_hash.php in the public_html folder of your website and place the following code in it:

<?php

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once 'includes/password.inc';
echo user_hash_password('123456');
die();
menu_execute_active_handler();

?>

Replace 123456 with your actual desired password. You can create and edit the file from your Site Tools > Site > File Manager.

Then, open https://yourdomainname.com/user_hash.php (replace yourdomainname.com with your actual domain name) in your browser and you will see a very long string. Copy the string and go to your Site Tools > Site > MySQL > phpMyAdmin. Select the database of your website > SQL and type the following text:

update users set pass=md5(NEWPASS) where uid = 1;

Change NEWPASS with the string you copied earlier and click on GO.

If you are able to log in after you changed the password, immediately delete the user_hash.php file from your website to prevent third parties from gaining access to your Drupal account.

Share This Article