How To Reset Drupal Eight Administrator Password Using Phpmyadmin?

 administrator password using phpMyAdmin How to reset Drupal 8 administrator password using phpMyAdmin?
This post describes inwards brief the steps to reset the Drupal 8  administrator password inwards representative you lot forget them. Writing downward passwords are a large no no, together with no affair how difficult nosotros endeavour to retrieve passwords, sometimes, nosotros may missy it, peculiarly if you lot convey diverse unlike password for unlike systems. And forgetting passwords likewise commonly happens on evolution systems when you lot laid approximately dummy or random passwords, phuff!, you lot no longer retrieve them. In this post, nosotros shall meet how to reset Drupal admin user password easily from phpMyAdmin. 

Refer to previous post if you lot are specifically looking for Drupal admin password reset on Drupal 7.

How to reset password on Drupal production sites?
 
If it is a production site, it is advised to reset password using the “forgot password” link to permit Drupal shipping a password reset link to the user account’s email. This simpler together with safer than using approximately scripts to reset password. 
How to reset password on Drupal evolution sites?
On local evolution server, nosotros mightiness non convey a provision to permit Drupal sent emails (Email server non installed / configured etc.) So, the “forget password” link may non last of whatsoever work to reset Drupal admin password. 
However, on evolution sites, nosotros convey access to ascendancy trace equally good equally to phpMyAdmin. So, nosotros tin reset passwords for whatsoever user from phpMyAdmin past times running approximately scripts. But equally you lot mightiness already know that passwords inwards Drupal are hashed. So nosotros ask to know the hash code of a password earlier running such SQL command.

Method 1: Using password hash : requires access to ascendancy line

This method requires access to SSH on production server to generate the password hash. Refer to Method 2, if SSH access is non available on production site. Otherwise, you lot tin likewise work the hash provided below straight inwards phpMyAdmin.
The steps involves:
  • Generate password hash
  • Use the password hash inwards phpMyAdmin to reset password
To generate Drupal password hash, work the “password-hash.sh” file located at C:\xampp\htdocs\drupalsite\scripts tin last used to generate hashed password. On production sites, it should last at “yourserver\htdocs\drupalsite\scripts”.
To execute the inwards a higher house script “password-hash.sh” on production server would require SSH access. Some hosting environments practice non allow SSH access to the spider web server where a Drupal site is installed which makes it impossible to recover the Drupal administrator trouble concern human relationship password via the command-line. Refer to Method 2, if SSH access is non available.
If SSH access is available, you lot tin execute the “password-hash.sh” file for a detail password give-and-take together with work it. 
The next is an representative on local Drupal site running on Windows + XAMPP. The procedure is similar for production or evolution server.
  • Open Windows PowerShell
  • Navigate Drupal top dog directory (or C:\xampp\htdocs\drupalsite\ inwards this example)
  • From the root of the drupal site inwards PowerShell, run the command: 
php core/scripts/password-hash.sh admin@123

where admin@123 is the password nosotros wishing to generate the hash code for.

 administrator password using phpMyAdmin How to reset Drupal 8 administrator password using phpMyAdmin?
  • Copy the hashed code generated from PowerShell which is “$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz” for admin@123.
  • Open phpMyAdmin
  • Open the database
    • Open tabular array “users” (for Drupal 7)
    • Open the “users_field_data” tabular array (for Drupal 8)
  • Against the detail user you lot wishing to alter the password, double click on the hashed password displayed inwards phpMyAdmin and supersede it alongside the novel password hash generated / copied from the inwards a higher house step.
 administrator password using phpMyAdmin How to reset Drupal 8 administrator password using phpMyAdmin?

  • Go to flood table inwards DB
    If you lot are running a non-production server, exactly truncate this table, otherwise await for anything that is flagging your IP alongside logging in. delete those records.
  • Go to cache_entity table inwards DB
    If you lot are running a non-production server, exactly truncate this table, otherwise await for anything that is flagging your IP alongside logging in. delete those records.
  • Now login to the Drupal site alongside the novel password “admin@123”
  • After login, alter the password past times clicking on the edit user tab if desired.
Note: 

Now that you lot know the hash code for admin@123 is “$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz” (without quotes), you lot tin straight access phpMyAdmin together with update the password equally described inwards a higher house without generating a password hash.

Run the next SQL Script on the database:

UPDATE users SET overstep =’$S$DDSxOXL9.OZIu1m92JhljBtc2taWqsKBTJasNCLoHOLsSJwg4Czz’ WHERE uid = 1;

Method 2: Drupal 8 Admin Password Reset without SSH access

The steps described inwards Method 1 requires SSH access on production server to generate the password hash. If on evolution system, the inwards a higher house method 1 should likewise work. If you lot are on production server together with does non convey SSH access, this method may likewise last used (Thanks to Drupal Documentation here).

Excerpt from the link almost the script below: 

The password reset method described below uses a PHP script that must last uploaded to the spider web server to reset the administrator password. The powerfulness 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 amount Drupal bootstrap inwards corporation to obtain access to the necessary functions that generate the administrative password together with hence update the database alongside the novel password that you lot specify via the URL when you lot execute the script through the spider web browser.”
Follow the steps described below to reset Drupal 8 Admin password:
  • First, create a file alongside a random elevate (pwdreset000.php for example).
  • Open the file created inwards a higher house to edit. 
  • Copy together with glue the next code into the file created above, together with salve the file. 
<?php use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request;  if (pathinfo(__FILE__, PATHINFO_FILENAME) == 'admin-pass-reset') {   die('Please alter your file elevate 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 alongside ?pass=PASSWORD laid inwards 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 equally before long equally possible"; 
 
 
  • Upload the file to the root of the Drupal installation directory (using FTP or Web Host’s File Manager)
  • Execute the script, past times requesting the file inwards a spider web browser using the next URL pattern:
http://yoursite.com/pwdreset000.php?pass=mypassword 

In the inwards a higher house URL,
– supersede yoursite.com alongside your actual domain name,
– supersede pwdreset000.php alongside the actual file elevate you lot specified inwards mensuration 1 above,
– supersede mypassword with the desired novel password.

Note: It is highly recommended to pick out a password that contains upper together with lowercase letters together with numbers, together with is at to the lowest degree 12 digits inwards length. 

  • If the script executes successfully, you lot volition meet the text “Done” inwards your spider web browser. 
  • The password of the administrative trouble concern human relationship created when installing Drupal (i.e., user/1) volition last changed to “mypassword” (or whatever password you lot specify).
  • Finally, delete the file from the Drupal root directory. (very important)

Reset administrator trouble concern human relationship username along alongside password using the script above:

If you lot can’t retrieve the username of the administrator account, inwards the script above, change

//    ‘name’ => ‘admin’ to     ‘name’ => ‘admin’

together with the username volition likewise last changed to “admin”.

You may likewise reset the administrator’s electronic mail address inwards the same way, past times removing the // inwards the for the electronic mail address inwards the script above.

Refer to previous post if you lot are specifically looking for Drupal admin password reset on Drupal 7.