Setup & site building · Guide
How to Reset a WordPress Password (5 Ways)

Short answer
To reset a WordPress password, click Lost your password? on the login page and follow the email link, which expires after 24 hours. If email does not work, use WP-CLI with wp user update, change the password in phpMyAdmin, or add a temporary wp_set_password line to functions.php and remove it after logging in.
Key takeaways
- The Lost your password link is the fastest reset when your email works.
- Reset links expire after 24 hours, and a new request cancels the old link.
- WP-CLI is the safest method when email recovery is not available.
- In phpMyAdmin you must choose the MD5 function or the new password will not work.
- A wp_set_password line in functions.php must be removed right after you log in.
- Login sessions last 2 days, or 14 days with Remember Me ticked.
What is the fastest way to reset a WordPress password?
Click “Lost your password?” on the login page and follow the reset link sent to your email.
This is the method WordPress itself recommends first. The developer handbook says to “use the Lost your password? link on the login screen” when you forget your password.
It takes about 2 minutes when your email works, and you need no dashboard, hosting or database access.
| Method | What you need | Time | Use when |
|---|---|---|---|
| Email reset link | Access to the account email | About 2 minutes | Mail works |
| Profile change | Logged in | About 1 minute | You know the password |
| WP-CLI | SSH access | About 1 minute | Mail is broken |
| phpMyAdmin | Hosting panel | About 5 minutes | No SSH access |
| functions.php edit | File access | About 5 minutes | Last resort |
- Open your login page at
example.com/wp-login.php. - Click “Lost your password?” under the login form.
- Enter your username or the email address on the account.
- Click “Get New Password”.
- Open the email from WordPress and click the reset link.
- Type a new password twice and click “Reset Password”.
The reset link expires after 24 hours, and a new reset request cancels any earlier link for the same account. If the link says it is invalid, request a fresh one and click it at once. Check the spam folder if the email does not arrive within a few minutes.
How do you change your password while you are logged in?
Go to “Users → Profile”, click “Generate Password” or type a new one, and save.
Use this method when you know the current password and want a stronger one, or when an admin needs to change a user's password. Any user can change their own password from their profile page, and an administrator can change any user's password from “Users → All Users”.
- Log in to the dashboard.
- Go to “Users → Profile” for your own account, or “Users → All Users” and click “Edit” under another user.
- Scroll to “Account Management” and click “Generate Password” for a strong random password, or type your own.
- Click “Update Profile” or “Update User” to save.
WordPress shows a strength meter as you type. Pick a password the meter rates as strong: at least 12 characters with a mix of letters, numbers and symbols. Do not reuse a password from another site.
If you change your own password, you stay logged in, but other sessions on other devices are signed out.
WordPress.org gives the same steps in its Reset your password guide: open “Users → All Users”, click the username, then click “Generate Password”.
Learn WordPress also covers profile and password changes in its User management lesson.
How do you reset a password with WP-CLI?
Run wp user update USERNAME --prompt=user_pass over SSH and type the new password when asked.
WP-CLI is the method the developer handbook calls “the safest and most straightforward” when email recovery is not available. It changes the password through WordPress itself, so the hash is always in the right format. You need SSH access and WP-CLI installed on the server.
- Connect to your server over SSH and move into the WordPress folder.
- Run
wp user update USERNAME --prompt=user_pass, replacing USERNAME with the account name. - Type the new password when prompted. It does not show on screen, and the
--promptflag keeps it out of your shell history. - Log in at
wp-login.phpwith the new password.
To generate a random password instead, run wp user reset-password USERNAME --show-password. WordPress creates a new password, emails the user to say the password changed, and prints the password in the terminal. The email does not include the new password.
Use --show-password with care, because the password appears in plain text in terminal output and logs. You can read how to install WordPress with WP-CLI if your server does not have it yet.
How do you reset a password with phpMyAdmin?
Open the wp_users table, edit the user row, and set user_pass to your new password with the MD5 function.
Use this method when you have hosting control panel access but no email and no SSH. The developer handbook gives these exact steps and warns that direct database edits are high risk, so back up the database first and check you are editing the right user row.
- Log in to your hosting control panel and open phpMyAdmin.
- Select your WordPress database in the left sidebar.
- Open the
wp_userstable. Your prefix may differ, so check$table_prefixinwp-config.phpif the table name looks different. - Click “Edit” on the row for the user you want to reset.
- In the
user_passfield, select “MD5” from the function dropdown and type the new password. - Click “Go” to save.
Selecting MD5 is required for this method. WordPress stores hashed passwords, so plain text typed into user_pass will not work.
After the next successful login, WordPress replaces the temporary MD5 hash with a stronger hash on its own. If the email is the problem rather than the password, see the guide on how to fix password reset email not received.
How do you reset a password by editing functions.php?
Add one line with wp_set_password() to your active theme's functions.php, load the site once, then remove the line.
This is an emergency method for when you have FTP access but no database tool and no SSH. It works, but it is the least safe of the 5 ways, because a password left in a theme file is a security hole. Remove the line as soon as you have logged in.
- Connect with FTP or your host file manager and open the active theme folder in
wp-content/themes. - Download
functions.phpand keep a copy. - Add this line at the end, with the user ID of the account (1 is usually the first admin):
wp_set_password( 'YourNewPassword123!', 1 ); - Save and upload the file, then load any page on the site once.
- Log in with the new password.
- Remove the line from
functions.phpat once and upload the file again.
If you skip step 6, the password resets on every page load and anyone who reads the file learns it. A child theme is the safer place for any lasting code change; see how to create a child theme in WordPress.
How long does a password reset link last?
A WordPress password reset link expires after 24 hours.
The reset key is hashed and stored with a timestamp, and WordPress rejects keys older than 24 hours. The message does not always say the link expired; it may simply say the key is invalid.
A new reset request also cancels the old link, so clicking a link from an earlier email after requesting a second one will fail.
If you need more time, ask an administrator to reset the password with WP-CLI or phpMyAdmin instead. Do not share reset links by chat or email forwarding, and never post one in a public support forum, because anyone with the link can set a new password for the account.
What if the reset email never arrives?
Check the spam folder first, then check that the site can send email at all.
A missing reset email usually means a mail problem, not a password problem. Run these 4 checks in order:
- Look in spam, junk and promotions folders for mail from your site.
- Confirm the email address on the account is correct in “Users → All Users” (you need another admin account for this).
- Send a test email from a form or a plugin to see if any mail from the site arrives.
- Ask your host whether the server can send mail, or set up SMTP so WordPress sends through a real mail service.
If the site cannot send mail, no reset link will ever arrive, and the WP-CLI or phpMyAdmin method is the way back in. The full fix is in the guide on how to fix password reset email not received.
While you are locked out, read how to fix locked out of wp-admin for the wider set of lockout fixes.
How do you pick a strong new password?
Use at least 12 characters with upper and lower case letters, numbers and symbols, and store it in a password manager.
WordPress accepts any password you type, so the strength is up to you. A short or common password is the fastest way back into a hacked account, so treat the reset as a chance to fix a weak password for good.
- Use a password manager to generate and store the password.
- Never reuse a password from your email, bank or another site.
- Turn on two-factor authentication in WordPress so a stolen password alone is not enough to log in.
- Change the password again if you ever shared it with someone who no longer needs access.
Login sessions last 2 days by default, or 14 days when “Remember Me” is ticked on the login page, according to the developer handbook. That means a password change signs other sessions out, but a session on a shared computer may stay live for up to 2 days unless you log out everywhere.
What mistakes should you avoid?
Do not leave a reset line in functions.php, and do not type a plain-text password into the database.
The 5 mistakes below cause most reset failures:
- Clicking an old reset link after requesting a new one, which always fails.
- Typing a new password into
user_passin phpMyAdmin without choosing the MD5 function. - Leaving the
wp_set_password()line infunctions.phpafter logging back in. - Using
--show-passwordin WP-CLI on a shared screen or a logged terminal. - Reusing the same weak password that caused the lockout in the first place.
After a reset, log in, open “Users → Profile”, and confirm the account email is one you still control. That one check makes the next reset far easier.
Frequently asked questions
Can I reset a WordPress password without knowing the old one?
No. Clicking Lost your password? sends a reset link to the email address on your account, and that link works without the old password. The link expires after 24 hours, and a new request cancels any earlier link. If you cannot reach that email address, use WP-CLI or phpMyAdmin instead.
Why does my WordPress password reset link say invalid key?
It has expired or been replaced. Reset links last 24 hours, and requesting a new link cancels the old one. The error message often just says the key is invalid. Request a fresh link and click it at once, and check that no caching plugin is serving a stale copy of the login page.
Is the functions.php password reset method safe?
It is safe when you remove the line right after logging in. The line runs on every page load while it is there, so leaving it in place resets the password again and again and exposes the password to anyone who can read the file. Use WP-CLI or phpMyAdmin when you have the choice.
How do I change my WordPress password while logged in?
Go to Users, Profile and click Generate Password, then Update Profile. You can do this for your own account at any time. An administrator can change any user's password from Users, All Users. A password change signs out other sessions on other devices.
Can I reset a WordPress password from the command line?
Yes. If you have SSH access, run wp user update USERNAME --prompt=user_pass and type the new password when asked. The developer handbook calls WP-CLI the safest method when email recovery is not available, because it changes the password through WordPress itself.
Sources
- Logging In WordPress Developer Resources
- Roles and Capabilities WordPress.org
- WP-CLI WP-CLI
- Reset your password WordPress.org
- User management Learn WordPress
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


