3

Have an old VM with Drupal configured on it, and I can't recall the admin password. The password-recovery process sent me a link to reset the password, but the page generated said "Access Denied".

I then tried directly editing the Drupal users table in MySQL. This would have worked, except for the fact that the Salt module was installed and therefore the hash was invalid.

I'm not sure where to go from here; any ideas?

hewhocutsdown
  • 273
  • 4
  • 13

4 Answers4

1

It seems you already solved the problem but here is an answer anyhow. Connect to the mysql database and do the following:

  • select value from variable where name='salt';
  • update users set pass=md5('newpassSALT') where uid=1; Where SALT is the value noted above.

The password should be reset to "newpass".

Craig
  • 611
  • 3
  • 5
  • I'm no longer able to test this, but I'll trust you on it; I can see that salt value on my new server. – hewhocutsdown Feb 03 '10 at 14:37
  • This method didn't work for me: here's what did: http://serverfault.com/questions/104285/resetting-salted-drupal-admin-password/236106#236106 – Daniel Feb 16 '11 at 10:03
1

I had no luck with the MD5('newpassSALT') method described in the accepted answer, so here's what worked for me. Note that you need to substitute your own values for the following:

  • /var/www/path/to/drupal : the location your Drupal is installed
  • mynewpassword : your desired password
  • drupaluser : the drupal database user
  • drupaldb :the drupal database schema

Step by step:

# cd /var/www/path/to/drupal
# scripts/password-hash.sh "mynewpassword"
password: mynewpassword     hash: $S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy

# mysql -u drupaluser -p
enter your password:

mysql> use drupaldb
Database changed
mysql> update users set pass='$S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy' where uid=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)
Daniel
  • 121
  • 5
  • I assume this is on a new drupal 7 install? The newpassSALT solution is specifically for an old drupal install with the "SALT" module installed. – Craig Feb 19 '11 at 00:20
  • +1, this one really works for Drupal 7, thanks for sharing the hash for `mynewpassword`! Simply updating the appropriate record (for the user whose password I want to change) in phpMyAdmin with the hash you wrote, and then logging in with the appropriate username and `mynewpassword` works. Of course, this password should be changed after logging in immediately. :) (By the way, the simple MD5-methods in other answers only worked for <= Drupal 6. Drupal 7 doesn't use this "simple" password storing method anymore.) – Sk8erPeter Nov 25 '13 at 13:26
0

Do you have a second non-admin account on your drupal system that does work? Is it also using the slated password? Are you able to directly edit the mysql table and copy the password from an known account to the admin account?

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • I have a non-admin account, it suffers from the same problems. I can directly edit the mysql table, but I don't know how to recreate a salted value in order to sign in again; simply using "pass = md5('password')" doesn't work. – hewhocutsdown Jan 19 '10 at 21:16
  • Also, I tried moving the salt folder out of the sites/all/modules directory, to no effect. – hewhocutsdown Jan 19 '10 at 21:17
0

Your ending the wrong database! The mysql.user table is specifically for mysql accounts to access Drupal's database. If drupal is saying "access denied" then it probably has access to its database and you forgot drupal's admin password. I highly reccomend using phpMyAdmin for this.

1. Login to phpMyAdmin
2. Select the database which Drupal use from the drop-down menu on the left.
4. Click on the SQL tab.
5. In the text field on the page type the following text:
update users set pass=md5('NEWPASS') where uid = 1;

the uid of 1 is the admin, you can change the passwords used by other users by changing the uid in this query.

Rook
  • 2,655
  • 6
  • 27
  • 35