Account recovery guide

How to reset a WordPress password: every method, safest first.

There are five ways back into a WordPress account. Each one needs a different kind of access, and each one bypasses more of WordPress's own safeguards than the one before it. Start at the top and stop at the first one that works.

Pick the method from the access you have

The right method depends less on what went wrong than on what you can still reach: an inbox, another administrator, a shell, the database, or only the files. This table puts them in order of safety.

MethodYou needRiskWrites the right hash format
1. Email reset linkThe account's inboxLowestYes, automatically
2. Another administratorA second admin accountLowYes, automatically
3. WP-CLIShell access to the serverLowYes, automatically
4. phpMyAdmin or SQLDatabase accessMediumOnly if you generate it correctly
5. wp_set_password() snippetFile access (SFTP or file manager)HighestYes, but runs until deleted

Methods 1 to 3 go through WordPress's own code, so the stored hash, session invalidation and any security plugins all behave exactly as designed. Methods 4 and 5 reach around WordPress — useful when nothing else is available, and easy to get subtly wrong.

On the login screen, choose Lost your password? and enter the username or email address. WordPress emails a single-use link; following it lets you choose a new password, which it hashes and stores in the correct format for the running version. This is the method every other one is a fallback for.

If the email never arrives, the problem is almost always mail delivery rather than the account — many hosts silently drop mail sent by PHP. The password reset troubleshooting guide covers SMTP, expired links and the other usual causes before you move further down this list.

2. Another administrator resets it

If a second administrator can still sign in, they can go to Users → All Users, edit the locked-out account, and use Set New Password (or Send Reset Link to trigger method 1 on your behalf). It is just as safe as the email flow and does not depend on mail at all. On multisite, a super admin can do the same from the network admin's Users screen.

3. WP-CLI on the server

With shell access and WP-CLI installed, WordPress itself performs the reset. Run it from the site's root directory:

Prompt for the new password, so it never lands in shell history wp user update admin --prompt=user_pass

Replace admin with the account's login, email or ID. The WP-CLI reset guide covers finding the right user, multisite targeting with --url, and why --prompt is safer than passing the password as an argument.

4. phpMyAdmin or a SQL query

With database access but no shell, you can write a new hash into the account's user_pass column directly. Two things have to be right: the table — whose prefix may not be wp_, see finding the users table — and the hash format. On WordPress 6.8 and later that is $wp$2y$; the password generator produces a strong password, its hash and the full statement in one step:

SQL — set one account's password hash
UPDATE wp_users
SET user_pass = '$wp$2y$10$…paste the generated hash…'
WHERE user_login = 'admin'
LIMIT 1;

The phpMyAdmin guide walks through the same change in the phpMyAdmin interface, including the MD5 emergency fallback and why you should set a fresh password through WordPress once you are back in.

5. The wp_set_password() emergency snippet

When all you have is file access, a must-use plugin can call WordPress's own wp_set_password(). Create wp-content/mu-plugins/reset-password-once.php with the snippet below, load any page of the site once, then delete the file immediately:

wp-content/mu-plugins/reset-password-once.php — delete after one page load
<?php
// Emergency reset. This runs on EVERY request until the file is deleted.
add_action( 'init', function () {
    $user = get_user_by( 'login', 'admin' );
    if ( $user ) {
        wp_set_password( 'replace-with-a-long-new-password', $user->ID );
    }
} );

This is last on the list for three reasons. The new password sits in plain text in a file on the server for as long as the file exists. Every request re-runs the reset and signs the user out again, so the account is unusable until the file is gone. And a typo in the file can take the whole site down with a PHP error. If the mu-plugins directory does not exist, create it; WordPress loads anything in it automatically, with no activation step.

After any reset

  1. Sign in and set a new password through your profile, so WordPress — not a pasted value — owns the final one.
  2. Check Users for administrator accounts you do not recognize; an unexpected lockout can mean someone else changed the password.
  3. If compromise is possible, rotate the salts to end every active session, and revoke unfamiliar application passwords.
  4. Remove any reset file, SQL file or note that contains the password.

Quick answers

What is the safest way to reset a WordPress password?

The email reset link on the login screen. It goes through WordPress's own reset flow, expires after use, and stores the new password in the correct hash format automatically. Use the other methods only when the email cannot be received.

Can I reset a WordPress password without email?

Yes. Another administrator can set it from the Users screen, WP-CLI can set it from the server shell, and with database access you can write a new hash into user_pass. Fix mail delivery afterwards so the normal flow works next time.

Can I just put a new password into the database as plain text?

No. WordPress compares the stored value against a hash of what you type, so a plain-text value never matches and the account stays locked. Store a hash generated for the site's WordPress version, or MD5 as a one-time emergency fallback.

Does resetting the password log out other sessions?

Yes, for that account. WordPress mixes a few characters of the stored hash into the key that signs its login cookies, so any change to user_pass — through WordPress or a raw SQL update — invalidates cookies issued with the old hash. Other accounts stay signed in; rotate the salts to sign everyone out.

Primary references: wp_set_password(), wp user update and Reset your password.