密码已重置,但 Dupal 在用户 table 中没有密码字段?

Password reset but Dupal doesn't have pass field in the users table?

我正在尝试 reset the admin password for a Drupal account,但 users table 中似乎没有 pass 字段。

UPDATE users
SET pass ='$S$CTo9G7Lx28rzCfpn4WB2hUlknDKv6QTqHaf82WLbhPT2K5TzKzML'
WHERE uid = 1;

相反,它在 table users_field_data 中有一个 pass 字段。这对 Drupal 意味着什么?

我在 users_field_data table.

上找不到任何文档

我使用的是 Drupal VERSION = '8.2.7';

mysql> show create table users;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                    |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| users | CREATE TABLE `users` (
  `uid` int(10) unsigned NOT NULL,
  `uuid` varchar(128) CHARACTER SET ascii NOT NULL,
  `langcode` varchar(12) CHARACTER SET ascii NOT NULL,
  PRIMARY KEY (`uid`),
  UNIQUE KEY `user_field__uuid__value` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='The base table for user entities.' |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Drupal 7 的 schemausers table.

中肯定有一个 pass 字段

您可能希望在 pass 字段周围使用反引号:

UPDATE users
SET `pass` ='$S$CTo9G7Lx28rzCfpn4WB2hUlknDKv6QTqHaf82WLbhPT2K5TzKzML'
WHERE uid = 1;

如果这不起作用,并且仔细检查 MySQL 客户端中的 table 没有显示字段,我担心有人无意中删除了它。不过,此数据库结构在 Drupal 8 中可见,因此请仔细检查您的版本。

您正在使用 Drupal 8

Drupal 7 和 Drupal 8 有不同的 tables 和架构。

这些说明适用于 Drupal 7。如果 users table 中没有 pass 而你有 users_field_data you need to find the other instructions for Drupal 8.

提示这很简单

  1. 您正在更改 table 名称,users_field_data 实际上是正确的 table。

    UPDATE users_field_data
    SET pass= hash_generated_with_password-hash.sh
    WHERE uid = 1;
    
  2. 另外还得删除缓存

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

尝试使用 drush 重置密码

drush upwd USERNAME PASSWORD