Resetting Drupal Admin Password
If you ever forget your administrator password for Drupal, there a few ways of recovering it. It may sound silly but when you are setting up test systems - it's easy to do.
The first thing to note is that your admin user account is always user 1. This simply means in the database in your user table; the admin user account has the id of 1. The reason for this is the administrator account is the first account created when you install Drupal. Thus, it is safe to assume user 1 is always your administrator account.
Resetting via 'forgot password link'
If you have setup your mail system, the easiest way is to request a password reset link. You will receive this e-mail to the address that is registered on the account. Use the URL below and substitute the domain with yours.
Drush to reset your password
If you use Drush (if you don't - look into the Drush project on Drupal.) you can issue a command via command line. Using this method, you can change the password for any account.
Use the code below and change your_new_password to what you desire.
drush upwd --password="your_new_password" admin
...which generates a link for resetting your password. This is the same as requesting a new password via the website.
MySQL to reset Drupal 6 password
I use MySQL as my choice of DBMS. It's free, fast - perfect for both commercial and personal use. Since Drupal 6 uses a MD5 algorithm to encrypt passwords, we will be using the relevant built-in MD5 function. This way of storing passwords is now frowned upon since no salt is used and rainbow tables can be used to break weak passwords.
Anyway, use the code below onced logged into the MySQL command prompt. If you are not sure how - usually typing MySQL in your terminal will log you in depending on config.
UPDATE 'users' SET pass=MD5('your_new_password') WHERE uid=1;
MySQL to reset Drupal 7 password
Finally in Drupal 7, we have s3cure passwords! Drupal 7 now uses SHA-256 with a salt, which is encoded with base64.
To reset your Drupal 7 admin password, we need to use one of Drupal's scripts. This script is located in your Drupal root in a folder named scripts.
So for Windows, run this script:
php .\scripts\password-hash.sh your_new_password
If you have a problem with PHP not being recognized, you more than likely need to add it to your system path. There are many tutorials out there to help you with that.
For other systems including Drupal on Linux and Mac:
Stop losing your passwords!