0

I want to refresh my DEV site with data from LIVE site.
(both sites have same modules because I play with new modules on my DEV site before I install/enable modules on the LIVE site).

I have set the database configuration to be exactly the same (except localhost for my dev site).
So I dump my database from live site and restore it on my dev site.
(I know I miss some files but I don't care about that.)
All is fine: I can view the dev site with data from the live site, until I try to login as administrator. There is no way to login, no error message; I am simply not logged in.
The password for the administrator user is the same on both the sites, of course.

I checked the hash of the passwords which are different in table users.
I assumed it was due to some salt, so I also copied the salt from sites/default/settings.php
It does not help: The administrator login is still impossible.
Then I reset the admin password on my dev site as explained in http://drupal.org/node/1023428, but it doesn't help: There is no way to log in.

What did I miss?

  • If you copied the DB exactly the users table should be identical, so the fact that the hash is different suggests the DB restore was incomplete. Did you restore into an empty database? It's always best to do that if possible as any missing tables will be apparent, plus the restore will run much faster. – Alfred Armstrong Apr 29 '13 at 13:05
  • I meant hash are different between LIVE and DEV site. Hash is different which is OK if salt defined in seetings.php is different. Conversely, same salt should produce same hash -- unless some other user-specific info (but invariant) is addded to compose the salt (which is a good practice). – gerard May 1 '13 at 13:04
  • Yes but when you copy a DB, the salt in settings.php is not relevant to what goes into the database tables. The salt is only used when a user is created on that environment. If their data has been added from a mysql dump, the salt has no bearing. So the password hash in the original DB and the one you copied to should be identical in both cases. – Alfred Armstrong May 1 '13 at 15:05
1

Solved by apache configuration, as described in Can't log in to Drupal instance after duplicating database
So to be complete :
1/ apache mod_rewrite must be loaded :
httpd.conf must include :
LoadModule rewrite_module modules/mod_rewrite.so

2/ the salt in sites/default/settings.php and the passwords hash (in table users) must be aligned :
If you keep the hash from the restored DB (the LIVE site), then you have to change the salt from your site (DEV Site) to align with the salt from the site you take the DB from (the LIVE site).

1

When login fails, you shall get the following error message:

Sorry, unrecognized username or password. Have you forgotten your password?

You say:

There is no way to login, no error message; simply I am not logged in.

This suggest that the problem is not with the admin passord, but something else (i.e. your restored site is somehow munged). In that case, you need to start restoring it from scratch.

Resetting the password will not help if the site is munged, but for the record:

There are several ways to reset the Drupal admin password. Here they are, sorted from the simplest to use to most difficult:

  1. Request a reset password link sent via e-mail (the most used method).
  2. drush upwd admin --password=<new_password> (as already mentioned by develkar).
  3. ./scripts/password-hash.sh <new_password> (as you've found out yourself).

Usually, all of these works. The shell-script method (#3) is very similar to the drush method (#2), but unlike drush, the shell-script method requires you to insert the generated password hash in the database yourself (using phpMyAdmin or similar tool).

0

If you have drush installed you can reset the password using:

drush upwd <username> --password=<new_password>

e.g. drush upwd admin --password=admin

this will reset the password of the user with username admin to have the password admin. You can change the password of any user using this command with Drush.

P.S - Make sure you are in your site's directory while using this command.

If you don't have Drush installed, I recommend you to install it. Please see Specific instructions for installing Drush on different platforms.

  • I don't know drush. I assume it somehow does the same as the php script described in drupal.org/node/1556488 (which I tried also). I would like also to understand what I miss for things to run fine. Thanks – gerard Apr 29 '13 at 12:49
  • In your post you've mentioned that you don't get any error or any warning. It is really hard to guess what went wrong. Might be the case of incorrect backup. How did you do the backup and then post it to local site? Did you use any module like "Backup and Migrate" to do so? – AjitS Apr 29 '13 at 12:54
0

Try to change the admin password on your production site (do it carrefully) and re-export your users table in your local dev environment

0

Another temporary trick to get into the site if you are using drush is:

drush uli

This will log you in as user 1 and give you the option to reset your password. This may help you during the debugging process.

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.