Singapore & Australia # 1 for Web Hosting & Domains
SG: +65 6914-7888   AU: 1300-863-436 Asset 1colo Help
Vodien Logo
  1. Home
  2. Knowledge Base
  3. CMS
  4. How to Reset Drupal Admin Logins

How to Reset Drupal Admin Logins

There are four options on how to reset Drupal admin credentials: 

Via Drupal Admin Panel 

The login profile details can easily be edited on the Drupal admin panel. Follow the steps below on how to edit those details: 

Note: This process needs to have your access or current Drupal admin username and password.

Step 1. 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.  

Drupal Log In Page

Step 2. Click your username on the menu bar at the top of the page. 

Step 3. Click Edit profile 

Step 4. 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.  

Edit Admin Details in Drupal

Step 5. Scroll down and click Save after making changes on the profile. 

Drupal Admin Edit Profile Page Save Button

A message will show at the top of the page once changes have been successfully saved.  

Drupal Admin Profile 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. 

Step 1. 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. 

Step 2. Click Reset your password button.  

Step 3. Enter the username or email address in the box provided.  

Step 4. Click Submit 

Drupal Reset Your Password Page

A message stating further instructions are sent to the email will show on the next page like in the screenshot below. 

Drupal Reset Instructions Sent Message

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. 

Step 1. 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' => 'yourmail@example.com'
))
->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";

Step 2. 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.  

Drupal Reset Done via Php File

Step 3. Delete the uploaded file from the directory so that it can’t be accessed by anybody else.

Step 4. 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 yourmail@example.com 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: 

Step 1Log in to cPanel. 

Step 2. Click File Manager. 

Step 3. Go to your Drupal website files and locate the settings.php in this file path – sites/default/settings.php. 

Step 4. Right click on the file and select Edit. 

Step 5. Click the Edit button. 

Step 6. 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.  

Drupal Database Details in Settings File

Step 7. Go back to cPanel homepage by going back to the previous tab. 

Step 8. Scroll down to the icons under Databases and click phpMyAdmin. 

cPanel phpMyAdmin Button

Step 9. Click the database name that was obtained from Step 6. 

Step 10. Click the database table that ends with _users_field_data 

Drupal Users Field Table in PhpMyAdmin

Step 11. Click Edit on the row that you want to update.  

Edit Option in PhpMyAdmin

Step 12Update 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.  

Step 13. Click either of the Go buttons to save the changes.  

Edit Mail and Press Go Button in PhpMyAdmin

Step 14. 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. 

(Visited 545 times, 1 visits today)
Updated on March 15, 2021

Was this article helpful?

Related Articles