If you find yourself locked out of your own Drupal installation and are unlucky enough to not receive any password-restore emails (or your server not being able to send them) you need to set a new password directly in the database. As Drupal stores a salted sha512 hash (and no plain passwords, of course) you need to encrypt your new password before you can store it in your database.
To do this you can either use the Shell script called
password-hash.sh provided in the scripts folder of any Drupal installation. In case you don’t have access to a shell you can also use the user_hash_password function in PHP:
This could be put in your index.php temporarily after bootstrapping Drupal. After visiting your site a string will be displayed. Replace your admin’s password in the
users table in the database with that string and you can now log in with
require_once 'includes/password.inc'; echo user_hash_password('YourNewPassword'); die();