How to reset Drupal 10 password in the database

When you get this message: There have been more than 5 failed login attempts for this account. It is temporarily blocked. Try again later or request a new password.

And you have no way to reset your admin user password by e-mail (this usually happens on a development machine without any mail server configured) follow these steps:

  • Truncate flood table in the database as this stores the login attempts.
  • Login to the bash terminal and use this command to generate a new hashed password:
    ./web/core/scripts/password-hash.sh 'your_new_password'

    This will output:
    password: your_new_password         hash: $2y$10$HwoDapHkyco6kJTF552tK.drPAAqnGMr2rqKLAwiFspSstyzi8vei

  • Update the pass field inside the users_field_data table with the generated value.
  • Clear the cache using drush:
    ./vendor/bin/drush cr

You should now be able to login to your Drupal 10 instance with the admin user.

Tags