Reset administrator password in Drupal

When in Drupal 8, the password for user #1 (the administrator) is lost and the email notification don’t work, it is possible to set the password via a database query.

You’ll need access to your hosting server’s shell and database in order to reset administrator’s password in Drupal.

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:

Be careful not to include more or less characters as the hash.

In case of Drupal 7 the correct path will be

table is “users” instead of “user_field_data” and you don’t need to clean the cache.

Update the administrator’s password.

Now you need to update the user password, in our case we need to update the Administrator’s password thus UID for Administrator is 1 in both Drupal 7 and 8.

With the new password we need run the following SQL statement.

Cleaning the 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 no compromise the rest of cache of your system you can use the following SQL statement.

Now you should be able to login successfully!

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com