There are several methods to recover the Drupal administrator ("user 1") password. The fastest way is using drush for Drupal 7. For Drupal 8, DrupalConsole provide a suite of commands to recovery and manage users passwords.
Recover password with DrupalConsole (Only Drupal 8).
DrupalConsole offers several ways of recovering the administrator's password.
DrupalConsole can generate a one-time login link.
Clear login failed attempts for an account.
Request new password via e-mail
You can reset your password by requesting a new password at
Change password with a database query
Drupal 6 and below
Execute the following query on the Drupal database where 'givememypasswordback' is your new password. You will need to log into your database using phpMyAdmin or another tool.
UPDATE users SET pass = MD5('givememypasswordback') WHERE uid=1;
Recover password with Drush
Drush offers several ways of recovering the administrator's password.
Drush can generate a one-time login link.
drush upwd --password="givememypasswordback" "admin"
(where "admin" is the user name)