3

I made the mistake of removing the user login block through the web interface, and logged out.

Now, I don't have the login interface anymore. Does anyone know how to solve this or is re-installing the only solution?

Furthermore, when I access example.com/user, the log-in form is shown, but it doesn't accept my credentials anymore.


I think I have found the "issue": The login page on mysite/user is the default login page for mysite; however, the default login block that is displayed on the front page is the login for the Drupal 7 web interface. These two are completely separate, that is why my credentials weren't working on mysite/user.

So in conclusion, if you removed the default login block and logged out of the drupal 7 web interface, then you are in troubles.

Please correct me if I'm wrong.

  • 6
    Have you tried going to mysite.com/user? You should find the login form there even if you've removed the login block – Clive Mar 2 '12 at 17:54
  • I have just tried that and it does display the login fields. However it doesn't accept my credentials anymore...my credentials are simple "root" and "root"..would you happen to know why? thank you for the quick reply. – chlong Mar 2 '12 at 17:57
  • Check your users table in the database...is there an entry in there with user id of 0? – Clive Mar 2 '12 at 18:01
  • 5
    Good lord, no!! Drupal gets funny with logins if that record isn't there so I thought it was a good place to check :) Have you tried going old school...clicking the 'Request new password' link?! – Clive Mar 2 '12 at 18:03
  • 1
    @chlong Try going directly to mysite.com/user/password, that's the direct link to the request new password page – Clive Mar 2 '12 at 18:32
2

Jimajamma's answer is correct, but the real question here is: How do I hack a new password for user 1, given that I lost/corrupted/forgot my old one?

If you haven't turned off user registrations, create a new user. Now you have a password hash in your database for a known password. You could come up with some SQL to move this hash to user 1's password column, couldn't you? :-)

Then log in, change the password if you need to, delete the user you created, etc. And write it all down. :-)

  • The scripts directory contains password-hash.sh which can be run (./scripts/password-hash.sh "newpassword") to generate a new password hash for use in updating the database. – mechler May 3 '12 at 16:34
2

You can reset the password in the database. Make sure that you hash it correctly using /scripts/password-hash.sh (or manually if you're comfortable). Just as an example...

  1. cd /site/root

  2. ./scripts/password-hash.sh "test password goes here"

    This should return something like:

    password: test password goes here hash: $S$Dq18FZ8uh1pMdNYE3YMw3wWytBULp8a54T/ixwnrn3IyeQL/bopi

  3. drush sqlc

    This step uses drush to connect to your database. If you don't use drush, connect to your database in whichever way you are comfortable. I suggest trying drush. It is very powerful and will make many problems easier to solve and solutions easier to realize.

  4. UPDATE users SET pass='$S$Dq18FZ8uh1pMdNYE3YMw3wWytBULp8a54T/ixwnrn3IyeQL/bopi' WHERE uid=1;

You should then be able to log in as user 1 using password test password goes here.

  • @dkiscool: No, Drupal 7 does not use MD5 for user passwords. You can not change it directly in your database as it is hashed multiple times and enriched with a salt. – Berdir Apr 14 '12 at 11:23
1

Try http://www.yoursite.com/user.

  • Jima, thanks that works. But my credentials no longer work. Do you know why? – chlong Mar 2 '12 at 17:58
  • how far into your install were you when all of this happened? – Jimajamma Mar 2 '12 at 18:05
  • Pretty far..I did a few custom themes already, but if re-installing is the only way to go then...:( – chlong Mar 2 '12 at 18:07
  • 2
    CHeck out drupal.org/node/992400 for some drupal 7 ideas – Jimajamma Mar 2 '12 at 18:25
0

I dont know the reason why your credential are not working.But you can update password through the phpmyadmin. To reset your password,

  1. Go to users table in your db
  2. find the username root and click edit for edit that row
  3. Then in the password field give your new password
  4. And DON'T FORGET to use MD5 function to encript your password

If the above way is not easy to you then,

<?php 
   db_query("UPDATE users SET pass = MD5('newpwd') WHERE uid=1"); 
?>
  1. create a page and set the text format as PHP code
  2. Then paste the above code with replacing new password and click preview or save
  3. It will update the admin user password Here is the code
  • hi sathishkumar, i just did that with a direct SQL command. The SQL worked, but I still can't login... – chlong Mar 2 '12 at 18:11
  • Is it multisite? And drupal 7 or 6, which version are you using? – sathishkumar Mar 2 '12 at 18:13
  • Yes it is multi-site. To add a little more detail, after I press the 'Login' button, the page just refreshes and the username and password fields become empty again without login me in. – chlong Mar 2 '12 at 18:13
  • ok, then this can be a cookie issue!, Go to your settings.php, there check the cookie domain and you url is same? – sathishkumar Mar 2 '12 at 18:14
  • 6
    I think Drupal 7 uses a salt for passwords so a bog standard MD5 won't do any good here – Clive Mar 2 '12 at 18:16
0

I had the same problem today , and I solved it by updating some fields in drupal's database. I went to Block table in drupal's database. and executed this query :

"update block set status = 1 , region = 'any-visible-block-name' where theme = 'current-theme-name' and module='user' and delta='login'; "

then I returned to my website, and the authentification block appears in 'any-visible-block-name' that I specified in previous query.

Good luck and hope it help you :)

0

I solved the same problem by reseting the default theme to Bartik using drush:

  • first, i navigated to /var/www/website_folder and run
    drush vset theme_default bartik
  • after that, i went to my website page and manage to login as admin
  • than went to Appearance and set back old theme (the one that i was using when problem happend) and in Structure -> Blocks enabled User login block

That worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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