Change admin password in Drupal 7

I use the built-in Drupal 7 user module to register users, forgotten email passwords and all that.

I forgot my admin password. Do I have access to my site, which is hosted on 1and1.com, and also has mysql access?

Is it possible to change the password or email address through SQL so that I can access the admin page?

If possible, how? Can you help me with this?

Thank!

+4
source share
7 answers

After several studies, I tried the following code, remembered it as a php file in the root directory

saved it as password reset -admin.php

<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once DRUPAL_ROOT . '/includes/password.inc';
if (isset($_GET['pass']) && !empty($_GET['pass'])) { 
$newhash = user_hash_password($_GET['pass']);
}
else {
die('Retry with ?pass=PASSWORD set in the URL');
}
$updatepass = db_update('users') 
->fields(array(
'pass' => $newhash,
// 'name' => 'admin',
// 'mail' => '<a href="mailto:yourmail@domain.com'">yourmail@domain.com'</a>;
))
->condition('uid', '1', '=')
->execute();
print "Done. Please delete this file immediately!";
drupal_exit();
 ?>

php :

 https://yoursite.com/password-reset-admin.php?pass=newpassword

..:) , .

, , .

+5

Drush, .

drush upwd admin --password=mynewpassword

admin - ; mynewpassword.

+6

, -. , drupal 7 .

Drupal 7. :

./scripts/password-hash.sh NEW_PASSWORD

NEW_PASSWORD , .

, (phpMyAdmin ) .

, Drupal MD5 .

+4

Drupal. .

Drupal 7:

$ PHP s/password-hash.sh 'your-new-pass-here'

SQL- :

UPDATE users_field_data SET pass='$S$Do7UQjqtEELNccdi92eCXcVJ2KnwUeHrSbK3YhFm8oR3lRJQbMB2' WHERE uid = 1;

Drupal 8 script :

$ php core/scripts/password-hash.sh 'your-new-pass-here'

:

UPDATE users_field_data SET pass='$S$Do7UQjqtEELNccdi92eCXcVJ2KnwUeHrSbK3YhFm8oR3lRJQbMB2' WHERE uid = 1;

:

DELETE FROM cache_entity WHERE cid = 'values:user:1';
+3

, ...

  • , .

  • yoursite.com/user/password .

  • reset, reset .

!

+1

!

"" PhpMyAdmin (, , Drupal, Prefix_ mywebsitename_, mywebsitename_users).

"pass", "uid" 1 (, 1 ).

: Admin_12345 is = >

$S $DifCVXg9tNtHadziyyQJQVLAaZzW5EgS6OjR56D.mk8MpNQs1II2

, , .

: Admin_12345 , .

0

.

0

Source: https://habr.com/ru/post/1543327/


All Articles