In this post we will know, how can we reset the Drupal 8 frontend admin user password. It is very easy just you have the server access to run the following commands -
Generate a new password
First, you have to generate a password hash that is valid for your site. Execute the following commands from the command line, in the Drupal 8 root directory:
php core/scripts/password-hash.sh 'your-new-pass-here'
Output:
password: your-new-pass-here hash: $S$EV4QAYSIc9XNZD9GMNDwMpMJXPJzz1J2dkSH6KIGiAVXvREBy.9E
Be careful not to include more or less characters as the hash. These hashes look somewhat like -
$S$EV4QAYSIc9XNZD9GMNDwMpMJXPJzz1J2dkSH6KIGiAVXvREBy.9E.
$S$EV4QAYSIc9XNZD9GMNDwMpMJXPJzz1J2dkSH6KIGiAVXvREBy.9E.
We will use the generated password later.
Update the user password.
Now you need to update the user password, in our case we need update the Administrator password, fortunately the UID for Administrator is 1 equal to previous versions of Drupal.
With the new password we need run the following SQL statement
Dealing with Cache
At this point if you try to login in the Drupal 8 website you will rejected, it's because the login system don't read directly the table users_field_data instead of a cache for entities is used.
To flush the cache for a specific user entity with compromise the rest of cache of your system you can use the following SQL statement.
Enjoy you I have successfully reset the Drupal 8 frontend admin user password.
Update the user password.
Now you need to update the user password, in our case we need update the Administrator password, fortunately the UID for Administrator is 1 equal to previous versions of Drupal.
With the new password we need run the following SQL statement
UPDATE users_field_data SET pass='$S$E5j59pCS9kjQ8P/M1aUCKuF4UUIp.dXjrHyvnE4PerAVJ93bIu4U' WHERE uid = 1;
At this point if you try to login in the Drupal 8 website you will rejected, it's because the login system don't read directly the table users_field_data instead of a cache for entities is used.
To flush the cache for a specific user entity with compromise the rest of cache of your system you can use the following SQL statement.
DELETE FROM cache_entity WHERE cid = 'values:user:1';
Enjoy you I have successfully reset the Drupal 8 frontend admin user password.
Credit: weknowinc