Frequently we come across Drupal sites (live or testing) where the user 1 passwords are not known to the owner of the site. You can retrieve the password by changing the email address of user 1 to your email address and then use the forgot password option to reset your password. But if you don't want to change the user 1 email address but instead just want to change the password of user 1 there is an easier alternative via the database.
You can run the following query directly in the drupal database to reset the password of user 1 to whatever you wish to set
UPDATE users SET password=MD5('whatever-password-you-wish-to-set') WHERE uid = 1;
The query is not quite the same in Drupal 7 as there is salt used in Drupal 7 and you need to put in a bit of extra effort to get the password hash. First you have to get the password has to be used. You can do this by running
from the root of your drupal installation. This will output the password hash in your terminal. Copy this hash. Then run the following query in your database
UPDATE users SET password='password-hash' WHERE uid = 1;
where password-hash is the has you got when you ran the script given earlier.
The assumption is that you have access to the Drupal database. If you don't have access to the Drupal database but still wish to login as user 1 you should check out our article on how to login as user 1 to your Drupal database. Again the assumption is that you have ftp access and that you are authorized to do so. If you are not then probably you are not doing it right.