How to Reset the WordPress Admin Password When Locked Out
Locked out of WordPress? Reset the admin password with the lost password link, WP-CLI, phpMyAdmin or MySQL, or create a new admin user from the terminal.

Contents
If you need to reset the WordPress admin password, you are usually in one of two situations: you forgot the password, or the reset email never arrives. Either way, you can get back in without reinstalling anything, because the password is just a value in the database that you can change in several ways.
This guide covers the "Lost your password?" link and why the email often goes missing, resetting the password with WP-CLI, phpMyAdmin and the MySQL command line, your control panel's WordPress tool, creating a new admin user, finding a forgotten username and securing the account afterwards.
Method 1: the "Lost your password?" link
The simplest way is built into WordPress. Open https://example.com/wp-login.php, click Lost your password? under the login form, enter your username or email address and click Get New Password. WordPress sends an email with a link to set a new password. The link is valid for 24 hours by default.
This only works if the email arrives. WordPress sends mail through the PHP mail() function on the server by default, without SMTP authentication, and many mailbox providers treat that as suspicious. Common reasons the email doesn't show up:
- It is in the spam folder, especially if the domain has no SPF, DKIM or DMARC records. Our Why emails go to spam guide explains how to fix that.
- The account's email address is old, mistyped or a mailbox that no longer exists.
- The server can't send mail at all, which is common on a VPS where no mail service is configured.
For the long term, install an SMTP plugin and send WordPress mail through a real mailbox. For now, use one of the methods below; they don't need email.
Method 2: WP-CLI over SSH
If you have SSH access and WP-CLI is installed, this is the fastest way. Go to the site's folder (usually public_html) and list the administrators:
cd ~/public_html
wp user list --role=administrator --fields=ID,user_login,user_email
Then set a new password for the user by ID or login:
wp user update admin --user_pass='N3w-Strong-Passw0rd!' --skip-email
--skip-email stops WordPress from sending the "password changed" notification. The downside of this command is that the password ends up in your shell history and can be seen in the process list while it runs. Two better options:
# Ask for the password instead of putting it on the command line
wp user update admin --prompt=user_pass
# Generate a random password and print it
wp user reset-password admin --skip-email --show-password
Without --skip-email, wp user reset-password sends the user a reset email instead, which helps only when mail works. If a broken plugin stops WP-CLI from running, add --skip-plugins --skip-themes to the command.
Method 3: phpMyAdmin
On shared hosting without SSH, phpMyAdmin in cPanel or DirectAdmin is the usual route. First check which database the site uses: open wp-config.php in the file manager and look at DB_NAME and the $table_prefix line.
define( 'DB_NAME', 'cpuser_wp123' );
$table_prefix = 'wp_';
- Open phpMyAdmin and select the database from
DB_NAMEon the left. - Open the users table. With the default prefix it is
wp_users; with a prefix likewpx7_it iswpx7_users. - Find your user in the
user_logincolumn and click Edit. - In the
user_passrow, delete the existing value, type the new password and choose MD5 in the Function column. - Click Go to save, then log in on
wp-login.phpwith the new password.
MD5 is not a secure hash, and that is fine here only because it is temporary. Since WordPress 6.8, new passwords are stored with bcrypt by default, but WordPress still accepts older hash formats, including a plain MD5 hash, and replaces the hash with a modern one the first time you log in successfully. So log in right after the change.
Method 4: the MySQL command line
On a VPS you can do the same over SSH with the MySQL client. Use the database user and password from wp-config.php:
mysql -u wp_user -p wordpress_db
SELECT ID, user_login, user_email FROM wp_users;
UPDATE wp_users SET user_pass = MD5('N3w-Strong-Passw0rd!') WHERE user_login = 'admin';
Replace wp_users if your prefix is different. As with phpMyAdmin, WordPress upgrades the MD5 hash on the next login. The password can end up in the client's history file (~/.mysql_history), so delete that line or change the password once more from wp-admin after you are in. If MySQL itself won't connect, our Error establishing a database connection guide helps.
Method 5: the control panel's WordPress manager
If WordPress was installed with the control panel's app installer or WordPress management tool, as described in our How to install WordPress guide, that tool can often reset the password too. Open the WordPress tool in the panel, select the installation and look for an option such as Change password, Users or Log in as admin. The menu names differ between tools, but none of them need email or database work.
Create a new administrator
If you'd rather not touch the existing account, for example because you are not sure who owns it, create a new administrator with WP-CLI:
wp user create newadmin you@example.com --role=administrator
Without --user_pass, WP-CLI generates a strong password and prints it once. Log in with it, fix the old account, and delete any account you no longer need under Users.
When you don't know the username
You can log in on wp-login.php with the account's email address instead of the username. If you don't know that either, the list of administrators shows both:
wp user list --role=administrator --fields=ID,user_login,user_email
In phpMyAdmin, open the _users table and look at the user_login and user_email columns. Note that display_name is the name shown on posts and is not the login name.
After you are back in
| Check | Why |
|---|---|
| Users → Administrator | An unknown admin account can mean a hack |
| The account's email | Keeps the reset link working next time |
| A strong, new password | Long, unique and kept in a password manager |
| Two-factor login | A stolen password alone is no longer enough |
| Login attempt limits | Slows down password guessing on wp-login.php |
If you see an administrator you don't recognise, treat it as a possible hack: change all passwords, end every session with wp user session destroy <user> --all, change the security keys in wp-config.php and follow our Website hacked: what to do guide.
Then turn on two-factor authentication with a 2FA plugin; our What is 2FA? guide explains how it works. Limit login attempts with a security plugin, or on a VPS block repeated failed logins with Fail2ban. Finally, use a long, unique password that you don't use anywhere else, and keep it in a password manager.
WordPress at Nodesty
Nodesty web hosting runs WordPress sites on AMD Ryzen 9 7900 servers with the LiteSpeed web server and NVMe storage. You reach phpMyAdmin, the file manager and your WordPress installation from cPanel or DirectAdmin, Imunify360 protects the site against attacks, and with JetBackup you can restore a working copy from the panel. Free SSL is included. If you want full control and WP-CLI on your own server, our AMD Ryzen 9 9950X VPS plans give you full root access and free daily backups kept for 7 days.
Frequently Asked Questions
Why don't I receive the WordPress password reset email?
By default WordPress sends mail through the PHP mail function on the server, and those messages often land in spam or are rejected because the domain has no SPF, DKIM or DMARC records. The email also only goes to the address stored on the user account, which may be outdated. Check the spam folder, set up an SMTP plugin, or reset the password with WP-CLI or phpMyAdmin instead.
Is it safe to use MD5 for the password in phpMyAdmin?
Only as a temporary step. WordPress still accepts an old MD5 hash, and the first time you log in it replaces it with a modern hash, bcrypt since WordPress 6.8. Log in right after the change so the MD5 value doesn't stay in the database, and use a new, strong password.
How do I find the table if it isn't called wp_users?
The table name starts with the prefix set in wp-config.php in the $table_prefix line. If the prefix is wpx7_, the table is wpx7_users. In phpMyAdmin you can also simply look for the table that ends in _users in the site's database.
I don't know my admin username. How do I find it?
You can log in with the email address instead of the username. If you don't know that either, run wp user list --role=administrator over SSH, or open the users table in phpMyAdmin and look at the user_login and user_email columns.
Does changing the password log out other sessions?
Not always. If you change the password directly in the database, sessions that are already logged in can stay valid until their cookies expire. If you suspect someone else has access, end all sessions with wp user session destroy and change the security keys in wp-config.php.
I found an admin user I don't know. What does it mean?
An unknown administrator account is one of the most common signs of a hacked site. Don't just delete it; first change all passwords, check the plugins and files and look for other changes. Our website hacked guide walks through the steps.
About the author
Nodesty Team · Infrastructure & Support
The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.
Related articles

WordPress Upload Size Limit: How to Increase It
Fix The uploaded file exceeds the upload_max_filesize directive in php.ini: raise the WordPress upload limit in cPanel, DirectAdmin, .user.ini or on a VPS.

502 Bad Gateway: Causes and How to Fix It on Nginx
Getting 502 Bad Gateway? Read the Nginx error log, restart PHP-FPM or your app, fix the upstream port or socket, raise pm.max_children, check Cloudflare.

There Has Been a Critical Error on This Website: How to Fix It
WordPress says There has been a critical error on this website? Find the PHP error with WP_DEBUG, disable plugins or the theme and fix memory limits.