How To Reset Drupal Admin Logins
There are four options on how to reset Drupal admin credentials:
Via Drupal Admin Panel
NOTE: This process needs to have your access or current Drupal admin username and password.
The login profile details can easily be edited on the Drupal admin panel. Follow the steps below on how to edit those details:
- Log in to your Drupal dashboard via the link yourdomain.com/user/login (replace yourdomain.com with the domain of your website) or via Softaculous Apps Installer in cPanel.
- Click your username on the menu bar at the top of the page.
- Click Edit profile.
- Enter the details need to be updated.
- Current password – Enter the same password used to log in. This can’t be skipped if there are changes made on this page.
- Email address – This is the registered email address of the user account where the reset link will be sent if you can no longer access the Drupal admin panel.
- Username – This is the username needed to login to Drupal admin panel.
- Password – Enter a new password.
- Confirm password – Re-enter the new password.
- Status – Choose whether to block the user or make it active.
- Roles – Choose if the user you’re editing is the Administrator or another Authenticated User.
- Picture – Add a picture for the current profile.
- Scroll down and click Save after making changes on the profile.
A message will show at the top of the page once changes have been successfully saved.
Via Reset Your Password Button
This process is applicable if you have access to the email address set up during Drupal installation as the instructions to reset the password will only be sent to that email.
- Log in to your Drupal dashboard via the link yourdomain.com/user/login (replace yourdomain.com with the domain of your website) or via Softaculous Apps Installer in cPanel.
- Click Reset your password button.
- Enter the username or email address in the box provided.
- Click Submit.
A message stating further instructions are sent to the email will show on the next page like in the screenshot below.
Via Uploading a Php File
This process can update your administration password, username and email address all at once. Due to security reasons, this is considered as the last resort. Make sure this uploaded file is deleted right after the reset of logins is completed.
NOTE: This process is only applicable for Drupal versions 8 and later.
Follow the steps below on how to upload the php file and reset the logins.
- Add a file to your website with the php script below. Upload the file alongside index.php.
<?php use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; if (pathinfo(__FILE__, PATHINFO_FILENAME) == 'admin-pass-reset') { die('Please change your file name to a random string to continue'); } // Boot Drupal. $autoloader = require __DIR__ . '/autoload.php'; $request = Request::createFromGlobals(); $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod', FALSE); $kernel->boot(); // Get password hasher service. $password_hasher = $kernel->getContainer()->get('password'); // Hash password. if (isset($_GET['pass']) && !empty($_GET['pass'])) { $newhash = $password_hasher->hash($_GET['pass']); } else { die('Retry with ?pass=PASSWORD set in the URL'); } // Update user password. $updatepass = Drupal::database()->update('users_field_data') ->fields(array( 'pass' => $newhash, // 'name' => 'admin', // 'mail' => '[email protected]' )) ->condition('uid', '1', '=') ->execute(); // Clean user 1 cache. Drupal::cache('entity')->delete('values:user:1'); print "Done. Please delete this file as soon as possible";
- Execute the file by accessing the link http://yourdomain.com/filename.php?pass=newpassword in your browser (replace yourdomain.com with your website’s domain, filename.php with the uploaded file’s name and newpassword with your Drupal new password).
TIP: Make sure to give the uploaded file a name that is hard to guess for security purposes. Make sure it ends with .php.
The page will tell you it is done as shown in the screenshot below.
- Delete the uploaded file from the directory so that it can’t be accessed by anybody else.
- Try to login to the Drupal admin page with the new password.
If the username and email address need to be updated, replace the admin with the new username and [email protected] with your email address then remove the 2 slashes before each bolded line for it to be included on the execution of the script.
Updating Admin Email in cPanel
This process is applicable if none of the email addresses and passwords are accessible. This will only need to have access to your web hosting server or cPanel. Follow the steps below on how to update your Drupal admin email address using phpMyAdmin:
- Log in to cPanel.
- Click File Manager.
- Go to your Drupal website files and locate the settings.php in this file path – sites/default/settings.php.
- Right click on the file and select Edit.
- Click the Edit button.
- Scroll down to the bottom of the page and take note of the values on lines 783 and 786. Other Drupal versions have it on lines 252 and 258.
- Go back to cPanel homepage by going back to the previous tab.
- Scroll down to the icons under Databases and click phpMyAdmin.
- Click the database name that was obtained from Step 6.
- Click the database table that ends with _users_field_data.
- Click Edit on the row that you want to update.
- Update the email address in the Value field of mail row. You can take note or update the username login that is indicated in the Value field of the name row.
- Click either of the Go buttons to save the changes.
- Follow the instructions on how to reset your Drupal logins via Reset Your Password button.
Do not hesitate to contact our Singapore or Australia Support Team if you have further questions.