-1

I'm trying to reset the admin password for a Drupal account, but it doesn't seem to have a pass field in the users table.

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

Instead it has a pass field in the table users_field_data. What does this mean about Drupal?

I can't find any docs on the users_field_data table.

I'm on 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)
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

3 Answers3

1

Drupal 7's schema definitely has a pass field in the users table.

You may want to use backticks around the pass field:

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

If that doesn't work, and a close inspection of the table in a MySQL client doesn't show a field, I'd worry about someone having inadvertently deleted it. This database structure is seen in Drupal 8, though, so check your version closely.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • see my update? I dumped it and no pass. It's in the `users_field_data` table. This isn't a fresh install it's a production product and I want to know what this means for the product or what customization happened – Evan Carroll Oct 31 '17 at 18:17
  • Drupal 8 appears to use the `users_field_data` model, so something very screwy is going on if your admin says you're on Drupal 7. – ceejayoz Oct 31 '17 at 18:18
  • I just saw that because it's in the CHANGELOG perhaps I'm on Drupal 8. What's the best way to find out what version of Drupal I'm on? – Evan Carroll Oct 31 '17 at 18:19
  • @EvanCarroll https://stackoverflow.com/questions/2887282/how-to-find-version-of-drupal-installed – ceejayoz Oct 31 '17 at 18:20
  • I see it I'm on const VERSION = '8.2.7'; – Evan Carroll Oct 31 '17 at 18:20
  • OK, then you're on Drupal 8. The answer to your question "What does this mean about Drupal?" thus is "absolutely nothing". Use a Drupal 8 tutorial for resetting your password. – ceejayoz Oct 31 '17 at 18:22
  • The answers not "absolutely nothing" but thanks for rejecting my previous guess that it was Drupal 7. =) – Evan Carroll Oct 31 '17 at 18:38
1

You're on Drupal 8

There are different tables and schema for Drupal 7 and Drupal 8.

Those instructions are for Drupal 7. If there is no pass in the users table and you have a users_field_data you need to find the other instructions for Drupal 8.

Hint it's pretty simple

  1. You're changing the table name, users_field_data is in fact the right table.

    UPDATE users_field_data
    SET pass= hash_generated_with_password-hash.sh
    WHERE uid = 1;
    
  2. In addition you have to delete the cache

    DELETE FROM cache_entity
    WHERE cid = 'values:user:1';
    
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0

Try to reset the password using drush

drush upwd USERNAME PASSWORD
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79