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
- Navigate to wp_users
- Edit user # 1 or any admin user
- Put in a new user_pass
- Make sure in function you select
md5
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 = '[email protected]'; # 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/