Some hosting environments do not allow SSH access to the web server where a Drupal site is installed which makes it impossible to recover the Drupal 8 administrator account password via the command-line. The following method should be employed as a "last resort" when the command-line based password recovery techniques do not work.
The password reset method described below uses a PHP script that must be uploaded to the web server to reset the administrator password. The ability to upload a PHP file to the server where the site is hosted is required for successful execution of this method.
Under the hood, the PHP script executes a full Drupal bootstrap in order to obtain access to the necessary functions that generate the administrative password and then update the database with the new password that you specify via the URL when you execute the script through the web browser.
Note: leaving this password reset script on your server after resetting the password constitutes a highly critical security hole that enables anyone to reset your administrator password. Use this script carefully, and always delete the script after you're finished using it.
- First, create a file with a random name (gh34tu9.php for example).
- Copy and paste the following contents into the file, and save the file.