更改drupal中的管理员密码7 [英] Change admin password in drupal 7

查看:98
本文介绍了更改drupal中的管理员密码7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用内置的Drupal 7用户模块,先用户注册,忘记密码电子邮件和所有的东西。



我忘记了我的管理员密码。我可以访问我的网站,它是托管在1and1.com上,还可以访问mysql?



是否可以通过SQL更改密码或电子邮件地址,以便我可以访问管理页面?



如果可能的话?你可以帮助我吗?



谢谢!

解决方案

经过几次研究,我尝试以下代码将其存储为根目录中的php文件

将其保存为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;如果
(isset($ _ GET [ '通'])及;&安培;!空($ _ GET [ '通'])){
$ newhash = user_hash_password($ _ GET [ '通']) ;
}
else {
die('Retry with?pass = PASSWORD set in the URL');
}
$ updatepass = db_update('users')
- > fields(array(
'pass'=> $ newhash,
//' '=> '管理',
// '邮件'=> '< A HREF =电子邮件地址:yourmail@domain.com'> yourmail@domain.com'< / A取代;
))
- >条件('uid','1','=')
- > execute();
打印完成,请立即删除该文件!;
drupal_exit();
?>

之后,通过以下方式访问php文件:

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

它只是工作.. :)希望它帮助别人。



请确保删除该文件。 >

I am using built in Drupal 7 user module, fore user registration, forgot-your-password-emails and all that stuff.

I have forgotten my admin password. I have access to my website which is hosted on 1and1.com and also have access to mysql?

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

If it possible how? Can you somebody help me with this?

Thanks!

解决方案

After several research I tried the following code stored 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();
 ?>

And after that access the php file through the following:

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

It just worked..:) Hope it helps others.

Please make sure you delete the file.

这篇关于更改drupal中的管理员密码7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆