fbpx

Help! I’ve lost my WordPress admin password and I need to urgently reset / recover the administrator password

Background

It’s a royal pain to loose your WordPress password, but do not fret as there are at least two ways to recover it. This article will provide two methods, one if you have PhpMyAdmin or database access, and two if you can upload files to the server.

Method 1 – How to Recover your WordPress Password If you have PhpMyAdmin Access

  1. Navigate to wp_users
  2. Edit user # 1 or any admin user
  3. Put in a new user_pass
  4. Make sure in function you select md5
  5. Click go.

Congratulations! Your password has been reset.

Method 1 – Upload file to server

Use S/FTP or SSH to get into the server, and then put the following PHP script into wp-content/mu-plugins/

<?php
/**
 * Upload to wp-content/mu-plugins/recover_my_password.php
 */
$login = 'foobar'; # New username
$password = 'barbaz'; # Password for the new user
$email = 'you@example.com'; # Email address of the new user
$ip = '127.0.0.1'; # Insert your IP, http://google.com/search?&q=what%20is%20my%20ip

if ($_SERVER['REMOTE_ADDR'] === $ip) {
    require_once(ABSPATH . WPINC . '/pluggable.php');
    require_once(ABSPATH . 'wp-admin/includes/' . 'user.php');

    $userdata = array(
        'user_login' => $login,
        'user_pass' => $password,
        'user_email' => $email,
        'role' => 'administrator',
    );
    $user_id = wp_insert_user($userdata);
    var_dump($user_id);
    die('delete me!');
}

References

https://www.wpbeginner.com/beginners-guide/how-to-reset-a-wordpress-password-from-phpmyadmin/
https://kuttler.eu/en/code/wordpress-emergency-admin/

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top