Refer to previous post if you lot are specifically looking for Drupal admin password reset on Drupal 7.
- Generate password hash
- Use the password hash inwards phpMyAdmin to reset password
- 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:
where admin@123 is the password nosotros wishing to generate the hash code for.
- 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.
- 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.
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;
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:
- 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:
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.