重置加盐的 Drupal 管理员密码

重置加盐的 Drupal 管理员密码

我有一台旧的虚拟机,上面配置了 Drupal,但我记不起管理员密码了。密码恢复过程向我发送了一个重置​​密码的链接,但生成的页面显示“访问被拒绝”。

然后我尝试直接编辑 MySQL 中的 Drupal 用户表。这本来是可行的,但由于安装了 Salt 模块,因此哈希值无效。

我不知道接下来该去哪里;有什么想法吗?

答案1

看来你已经解决了这个问题,但无论如何这是一个答案。连接到mysql数据库并执行以下操作:

  • 从变量中选择值,其中 name='salt';
  • 更新用户设置 pass=md5('newpassSALT'),其中 uid=1;其中 SALT 是上面提到的值。

密码应重置为“newpass”。

答案2

我没有用MD5('newpassSALT')上文中描述的方法接受的答案,所以以下是对我有用的方法。请注意,您需要用自己的值替换以下内容:

  • /var/www/path/to/drupal:你的 Drupal 安装的位置
  • mynewpassword:您想要的密码
  • drupaluser:drupal 数据库用户
  • drupaldb:drupal 数据库架构

一步步:

# cd /var/www/path/to/drupal
# scripts/password-hash.sh "mynewpassword"
password: mynewpassword     hash: $S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy

# mysql -u drupaluser -p
enter your password:

mysql> use drupaldb
Database changed
mysql> update users set pass='$S$C/mWw8UGcAyCwLDOiqRBOShJl8w2vVLsSzYvqCMuAg/LSncU16Iy' where uid=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

答案3

您的 drupal 系统上是否有第二个可以正常工作的非管理员帐户?它也使用预定的密码吗?您是否能够直接编辑 mysql 表并将密码从已知帐户复制到管理员帐户?

答案4

您关闭了错误的数据库!mysql.user 表专门用于 mysql 帐户访问 Drupal 的数据库。如果 drupal 显示“拒绝访问”,则它可能有权访问其数据库,而您忘记了 drupal 的管理员密码。我强烈建议使用 phpMyAdmin 来实现这一点。

1. Login to phpMyAdmin
2. Select the database which Drupal use from the drop-down menu on the left.
4. Click on the SQL tab.
5. In the text field on the page type the following text:
update users set pass=md5('NEWPASS') where uid = 1;

uid 为 1 是管理员,您可以通过更改此查询中的 uid 来更改其他用户使用的密码。

相关内容