0

I want to import users from one database to another, without changing password.

Suppose the password is saved as $S$DfAoLR.OJWl04tkzgnZeE3TdJHlz6NxBNpArOKhQAewyyHDFDD in the database; I want to save the same value in the database of the other site.

Can anyone suggest me how to achieve this?

1 Answer 1

1

Do this :

<?php
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$old_hash = md5('password');
$hash_count_log2 = 11;

$new_hash = user_hash_password($old_hash, $hash_count_log2);

if ($new_hash) {
  // Indicate an updated password.
  $new_hash  = 'U' . $new_hash;
}
?>

or you may check LINK1 or LINK2

Or you can directly import the data from one table to another :

INSERT INTO NewTable (ID, Name, Password)
  SELECT ID, Name, md5(Password) AS Password
  FROM OldTable
  WHERE ID BETWEEN 100 to 300

Check LINK once.

2
  • Thank for quick reply, But I don't want to change(hash) the password during import... I have modified the question. Commented Dec 12, 2014 at 7:59
  • Check my updated answer, I think that may help you.
    – Nishant
    Commented Dec 12, 2014 at 8:26

Your Answer

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

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