mysql

Reset the admin (user1) password in Drupal 9

Execute this from within the drupal directory

php core/scripts/password-hash.sh 'newPassword'
password: 'newPassword' hash: $S$EHKLUvRyA/5gpTqWsICIePmwOaQ4oPwMEAfRySELtZ4JdZ8uiYCo

Execute from within MySQL:

UPDATE users_field_data SET pass='$S$EHKLUvRyA/5gpTqWsICIePmwOaQ4oPwMEAfRySELtZ4JdZ8uiYCo' WHERE uid = 1;
DELETE FROM cache_entity WHERE cid = 'values:user:1';

mysql server restart

My mysqld runs on Ubuntu Hardy and after replacing the complete mysql data with a dump from another server the "/etc/init.d/mysql stop" command fails, because the system administration account doesn't work anymore. So I had to recreate it again:
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
The password can be obtained from /etc/mysql/debian.cnf.

Pages