1

I'm a new Drupal user.

Someone gave me a backup of their Drupal and .mysql content. I more or less followed these instructions: http://www.ostraining.com/blog/drupal/drupal-migrate/, except the site already had it's own settings.php, and so the site is now up and running.

The problem that I'm having now is that I can't log into the site to make any edits because I don't have a login. I tried to create an active user in phpmyadmin with an md5 hash password, and changed the user to an administrator. However I'm still not successfully logging in, the site says I'm still giving it the incorrect login info. When I try to recover/reset my password by email I am not receiving any emails. I am using Windows XP.

Is there any way I will be able to login to edit the site?

1

4 Answers 4

1

One way of solving your issue would be to update super admin (first user) password pragmatically, by creating a temporary php file under Drupal root folder and add the following code to it then access it from a browser.

<?php 

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


// load super admin user
$account = user_load(1);

// save user password
user_save($account, array('pass' => 'admin'));

echo "Super admin password has been changed";

Make sure to replace admin with desired password

3
  • 1
    Why not just use the correct way drupal.org/node/1023428 Apr 5, 2014 at 19:15
  • @DanielHarper there are many ways to solve this issue, and I mentioned only one way of solving it. You can submit another answer which others might benefit from :)
    – Aboodred1
    Apr 7, 2014 at 14:36
  • 1
    it's simple and it worked. i'm happy.
    – kimp
    Apr 11, 2014 at 17:42
1

The below SQL query would set the username and password of super admin user (uid 1) to admin and drupal respectively.

For d6 : UPDATE users SET name='admin', pass=md5('drupal') WHERE uid = 1;

For d7 : UPDATE users SET name='admin', pass='$S$Drl0vgZ9yuU9uc4JyaTMHxMPriC7q/PsOUOx52fCrVQSTpI/Tu4x' WHERE uid = 1;

where $S$Drl0vgZ9yuU9uc4JyaTMHxMPriC7q/PsOUOx52fCrVQSTpI/Tu4x is the encrypted text for password drupal. To generate hash text for different plain text Drupal ships with a php script password-hash.sh, cd to drupal root directory and run command "php scripts/password-hash.sh 'mynewpassword'" from command prompt to get encrypted password.

Source: http://knackforge.com/blog/sivaji/different-ways-reset-drupal-admin-password

0

You say:

When I try to recover/reset my password by email I am not receiving any emails.

You first need to set the e-mail address of the admin user (that is user #1) to your own e-mail address. You can do that using phpMyAdmin. Just change the field mail to your address in the table {users} for user with uid = 1. Also make a note of the user name of that user (that's in the field named name).

Now try to login with the user name of user #1. That will of course not work, but when you get the message:

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

you can request a password reset, and it will be sent to your e-mail address.

If you have drush installed, the following drush command will also reset the admin password (provided the admin user is named admin):

drush upwd admin --password=<new_password>
-2

drupal's admin uid is 1

in you phpmyadmin sql or mysql shell

view query to check admin record: select * from users where uid=1;

update query: UPDATE users SET pass = MD5('test') WHERE uid=1;

1
  • You forgot to add salt.
    – Mołot
    Apr 4, 2014 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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