0

Someone installed the drupal 8 site and did not share the password. I do not know what email he has used to install the site either. I do not have the password. In phpmyadmin, I clicked the database name. I ran the sql

UPDATE users SET pass = MD5( 'NewPassword' ) WHERE uid = 1;
Select * from users. 

1146 - Table 'xxx.users' doesn't exist

How can I retrieve the drupal 8 website password?

enter image description here

enter image description here

1
  • Don't you have access to the command line and Drush? Why don't you simply drush uli? – leymannx May 5 '20 at 19:21
1

Drupal does not store passwords, but rather password hashes. There is no way to recover the password. You can use Drush to either set a new password or generate a one-time log-in link:

  • Reset PW: drush upwd <username> --password="<password>"

  • One-time login-in link: drush uli <username>

3
  • This is in shared hosting server. I have not used drush in the past. Is there any CLI tool i can use in cPanel to run drush? Is there other workaround? – GreenTree May 5 '20 at 15:59
  • For shared hosting, I would put in a request with your provider for help. They might also be able to advise you on how to install or use drush. – Beau May 5 '20 at 17:00
  • @GreenTree – This site built with Composer or does your hosting have Composer then you have Drush as easy as composer require drush/drush. Even if not you could upload the vendor folder from your local machine and then run vendor/drush/drush/drush uli. – leymannx May 5 '20 at 21:01
1

Since you have access to the database, you can change the email for the superuser (uid: 1) to your email, in table users_field_data. Then follow the normal reset password link (user/password).

UPDATE `users_field_data` SET `mail` = 'user@example.com' WHERE `uid` = 1;

If you're getting an error that the users table doesn't exist, then you may have run the statement on the wrong database, or your tables may be prefixed, like xyz_users_field_data.

10
  • I was able to change the email. Prefix is drup_. Reset password did not send me reset password link. What are my options? I tried twice. It says further instruction has been sent. I checked spam folder as well. I do not see any email – GreenTree May 5 '20 at 18:01
  • 1
    It's unusual that it wouldn't send the email at all. I would double check everything. Make sure the username you use in the reset password form matches uid 1, and make sure you have your email address updated correctly for uid 1. If it's all correct, scan through the watchdog table to see if there are any errors. – JeremyM4n May 5 '20 at 18:25
  • UPDATE drup_users_field_data SET pass = 'ww@' WHERE uid = 1 I was able to change the password. But i used my email and this password but still could not access. Same table shows the name as admin. Assuming that is the user name. I still could not access using as admin name. – GreenTree May 5 '20 at 18:41
  • 2
    Well, you can set the password in the database, but unless it's a valid Drupal hash, you won't be able to log in with it. Did you see any errors in the watchdog table? – JeremyM4n May 5 '20 at 18:48
  • And yes, the name column is the username. So you would put admin into the password reset form. – JeremyM4n May 5 '20 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.