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

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

/var/www/www-root/data/www/testing.ru/core/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:

./core/scripts/password-hash.sh NewPass

Where NewPass is the new password that we want to set.

file

As a result of the script we get 2 values:

  • password - in which the password we set is marked;
  • hash - which displays the result of the hashing function.

We need to save the hash field value.

$S$DO7uUAM8/86kqb3rRocoF.k1jtCxzyR0lpfCMOEREzUpp189DvaF

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 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/sites/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 absent 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_field_data. In our case it is called users_field_data

file

Table users_field_data, 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 Aug. 27, 2019