To reset the administrator password in Drupal 7 there is a script, which should be run by connecting via SSH

After connecting to the server, you need to determine where the script is. Its default path is in the root directory of the site scripts/scripts/password-hash.sh.

/var/www/www-root/data/www/testing.ru/scripts/password-hash.sh

Change the directory to the root directory.

cd /var/www/www-root/data/www/testing.ru/  

Run the script with the following command:

./scripts/password-hash.sh new password

where the new password is the one we want to set.

file

As a result of the script we get 2 values:

  • password - which denotes the password we set;

  • hash - which displays the result of the hashing function.

We need to save the value of the hash field.

$S$D0hnDOfz5V9SFOlSyiPUJjiL51zJ2Kdh1Ix1ScJTvURtgwgF1aS/

Now we just need to put this value in the right field in the site database

Learn the name of the database with which the site works, you can in the configuration file settings.php, which is located in /sites/default/ from the root directory of the site.

/var/www/www-root/data/www/testing.ru/default/settings.php

Open this file, for example, via File Manager, and look for lines in it:

'database' => 'frnx_db',


'prefix' => ' ',

The values in these lines denote the name of the database the site works with, frnx_db and the database table prefix, which is not present in this case

After that, we need to get into the database itself, through phpMyAdmin in the MySQL section

Find the right database in the list and open it

In front of us is the database with which our site works. We need to find the table with the users of our site. Its name has the following form - Prefix_users. In our case it is called users

file

Table users, which contains information about all registered users of your site, you need to find the line with your account login and open it for editing by pressing Edit button.

file

To change your password, find the line with the name pass

file

  • in the Value field insert our hash, which we have generated using the script.

file

Let's click the Forward button to save our changes.

Updated Sept. 15, 2024