Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Can you provide a link to the download site for salt module you are using? I saw a couple different ones when I did a search. –  Zoredache Jan 20 '10 at 0:18
    
drupal.org/project/salt –  hewhocutsdown Jan 20 '10 at 14:50
    
Ended up rebuilding the VM; there wasn't enough data on it to make it worth the time I was spending trying to break back in. Thanks for the suggestions. –  hewhocutsdown Jan 23 '10 at 3:51

4 Answers 4

up vote 1 down vote accepted

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".

share|improve this answer
    
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 3 '10 at 14:37
    
This method didn't work for me: here's what did: serverfault.com/questions/104285/… –  Daniel Feb 16 '11 at 10:03

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?

share|improve this answer
    
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

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.

share|improve this answer
    
I misspoke; I meant the <drupaldb>.users table. This is what was done, but it did not correct the issue, due to the salt. –  hewhocutsdown Jan 24 '10 at 16:08

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)
share|improve this answer
    
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 0: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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.