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

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

问题描述

我正在使用内置的 Drupal 7 用户模块、前用户注册、忘记密码的电子邮件和所有这些东西.

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

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

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

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

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?

谢谢!

推荐答案

经过多次研究我尝试了以下代码将其作为 php 文件存储在根目录中

After several research I tried the following code stored it as a php file in the root directory

保存为password-reset-admin.php

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文件:

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.

请确保您删除该文件.

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

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