I forgot the password to the admin account
If the email you used to register the account is still active, or you still have access to it, then the easier way to change the password is using the "Request new password" link that appears in the login block, or the login page.



If you don't have access to the email you used to register it, you could change it in the "users" database table, and then request a new password.

If you don't have access to the database, but Drush is installed, then you can use the following command.

drush user-password &lt;username&gt; --password=&lt;password&gt;


Alternatively, you can use this command, which allows you to login as a user for once; once you are logged in, you can change the password for that account.

drush user-login &lt;username&gt;


The command return a link that can be used in the browser to access the site. If the username is omitted, the link is for the user #1.

If Drush is not installed, then you need to write a PHP file to change the password for the account. For Drupal 7, the following code works.

$account = user_load_by_name($username);
$edit['pass'] = $newpassword;
user_save($account, $edit);


Place the code in a file with extension .php, in the same directory containing the index.php file that comes with Drupal. Replace $username, and $newpassword with the username of the account you need to change the password, and the new password.

The following code work with both Drupal 6, and Drupal 7, but it requires you to know the user ID of the account.

$account = user_load($uid);
$edit['pass'] = $newpassword;
user_save($account, $edit);