Getting locked out of a WordPress site on localhost is frustrating, especially when you’re in the middle of a project.
We’ve run into it ourselves when switching between test sites, forgetting a complex password, or realizing the browser never saved our login.
The good news is that fixing it locally is quick. Since you have full access to your site’s database and files, you can reset the password in just a few minutes without needing email access.
In this tutorial, we’ll walk you through exactly how we reset a WordPress admin password on localhost using phpMyAdmin or WP-CLI. This means you can get back to building your website without any delays.

Why Resetting the Password Doesn’t Work on Localhost
When we say “localhost,” we’re talking about a local server, usually your computer. It’s a private space where you can build and test a WordPress site before going live.
We often use localhost to experiment with new plugins, design changes, or just learn how WordPress works. It’s a safe way to break things without worrying.
If you haven’t tried it yet, these guides can help you get started:
Now here’s the part that can be confusing for beginners. If you forget your admin password on a local site, the regular “Lost your password?” link won’t help.
That’s because WordPress normally sends a password reset email, but localhost setups can’t send emails unless you’ve set that up manually. And by default, most people haven’t.
Luckily, you don’t need an email to get back in.
We’ll show you two easy ways to reset your password on localhost, even if you’re completely locked out:
- Method 1: Reset WordPress Admin Password on Localhost Using phpMyAdmin
- Method 2: Resetting the Password via the Functions.php File
- Frequently Answered Questions About Resetting WordPress Passwords
- Bonus Resources for WordPress Admin
Method 1: Reset WordPress Admin Password on Localhost Using phpMyAdmin
If you’re using tools like XAMPP, WAMP, or MAMP, then phpMyAdmin should already be installed. We’ve used it many times to tweak things directly in the database, including resetting passwords.
phpMyAdmin gives you a visual interface to manage your WordPress database. It sounds complicated, but once you get the hang of it, it’s pretty straightforward.
Note: If you’re using LocalWP, you’ll see a tool called Adminer instead. It works just like phpMyAdmin, so you can still follow these steps easily.

To begin, open your browser and go to this address:
http://localhost/phpmyadmin/
You might be asked to log in. In most setups, the username is ‘root’ and the password field is left empty. If that doesn’t work, check the documentation for your specific local environment software.
Once you’re inside phpMyAdmin, look for your WordPress database name in the sidebar and click it.

You’ll see a list of tables inside that database. Find the one that ends in _users and click the ‘Browse’ link next to it.
Note: Most WordPress sites use wp_ as the prefix, but it could be different if you changed it during setup.

You’ll now see a list of users on your site.
Find the row with the admin username and click the ‘Edit’ link next to it.

This opens a form showing all the user data stored in the database. Scroll down until you find the user_pass field.
In the Value column, type your new password. Then, find the Function column next to it and select MD5 from the dropdown menu.

This creates a temporary password that will let you log in.
Click the ‘Go’ button at the bottom to save your changes.
Important: Using MD5 is not secure for a live site, but it works as a temporary key to get you back in on localhost. As soon as you log in, you must reset your password one more time inside WordPress.
To do this, go to Users » Profile from your admin dashboard. Enter your new password there and save it. This will make sure your password is saved correctly and securely using the latest WordPress hashing.
For details, see our guide on how to reset your WordPress password.

That’s it! You can now log in to your local WordPress site using the new password you just set.
Method 2: Resetting the Password via the Functions.php File
If you don’t have access to phpMyAdmin or prefer a different approach, you can reset your WordPress admin password by editing the functions.php file of your theme.
This method is straightforward and can be done quickly.
Step 1: Access Your Theme’s Functions.php File
First, you’ll need to locate the functions.php file for your active theme. To do this, navigate to the root directory of your WordPress installation on your localhost.
Depending on which software you are using, the location of the root directory may differ. For instance, if you are using Local, then your site will be located at:
C:\Users\yourusername\Local Sites\yoursitename\app\public\
Next, go to the /wp-content/themes/ folder. Inside, you’ll find a folder named after your active theme.

Inside your active theme folder, look for a file named functions.php and open it in a text editor like Notepad or TextEdit.
Step 2: Add the Code to Reset the Password
At the bottom of the functions.php file, you need to paste the following code:
function reset_admin_password() {
$user_id = 1; // ID of the admin user
$new_password = 'newpassword123'; // Your new password
wp_set_password($new_password, $user_id);
}
add_action('init', 'reset_admin_password');
The last line, ‘add_action(‘init’, ‘reset_admin_password’);’, is a WordPress hook. It tells your site to run this password-resetting code as soon as WordPress starts up.
Don’t forget to replace ‘newpassword123’ with a stronger password you want to use.
This code sets a new password for the admin user with the ID of 1. However, If you don’t know the user ID but know the admin email address, you can use this code snippet instead:
function reset_admin_password_by_email() {
$user_email = 'admin@example.com'; // Admin user's email address
$user = get_user_by('email', $user_email);
if ($user) {
$new_password = 'newpassword123'; // Your new password
wp_set_password($new_password, $user->ID);
}
}
add_action('init', 'reset_admin_password_by_email');
This code sets a new password (newpassword123) for the admin user associated with the specified email address.
After adding the code, save the functions.php file and refresh your localhost WordPress site in your browser. You should now be able to log in using the new password.
Step 3: Remove the Code
Once you’ve successfully logged in, it’s important to remove the code snippet from the functions.php file to avoid potential security risks.
If you don’t, WordPress will keep resetting your password every time a page loads, which could lock you out again or create a security vulnerability.
Simply open the functions.php file and delete the code you added earlier. Don’t forget to save your changes.
Frequently Answered Questions About Resetting WordPress Passwords
Here are some questions frequently asked by our readers about resetting the WordPress admin password on a local server:
What if I prefer using the command line?
If you’re comfortable with the terminal, then WP-CLI offers a super fast way to reset your password.
Just run this command:
wp user update 1 --user_pass=yournewpassword
Replace yournewpassword with whatever password you want to use. This method is especially handy for developers or anyone who prefers working in the command line.
It’s quick, clean, and doesn’t require editing any files or accessing phpMyAdmin.
Will these methods work on a live WordPress site?
They can, but you’ll need to be more cautious when working on a live site.
For live websites, the safest way to reset your admin password is by using the “Lost your password?” link on the login screen. WordPress will email you a reset link, assuming your site is set up to send emails correctly.
While the manual methods (like editing functions.php or using phpMyAdmin) also work online, they’re riskier. One small error in a live environment could crash your site or expose sensitive data.
Stick with the email method unless you know exactly what you’re doing.
I reset the password, but it still won’t let me log in. What should I do?
If you’re still locked out after resetting the password, don’t panic—just double-check a few common issues:
- ✅ Using phpMyAdmin? Make sure you selected MD5 when entering the new password.
- 🧼 Using functions.php? Remove the password reset code after it runs once.
- 🔁 Multiple local sites? Confirm you’re logging into the correct one.
If it’s still not working, then try clearing your browser cache, restarting your local server, or even testing in a different browser.
Once everything’s sorted, you should be able to log in smoothly.
Bonus Resources for WordPress Admin
The following are additional tips and tutorials on managing passwords and admin accounts in WordPress:
- How to Add an Admin User to the WordPress Database via MySQL
- How to Add an Admin User in WordPress Using FTP (Easy Tutorial)
- Beginner’s guide to receiving WordPress Emails from Localhost with SMTP
- How to Easily and Securely Manage Passwords (Beginner’s Guide)
- How to Password Protect Your WordPress Admin (wp-admin) Directory
We hope this article helped you reset your WordPress admin password on a local server. You may also want to see our tutorial on creating a temporary login for WordPress or take a look at our guide on how to add one-click Google login in WordPress.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Ezichukwu
thank you admin, the second method worked for me
WPBeginner Support
Glad to hear it worked for you
Admin
meli
thank you sooooo much! I was panicking and I was working on my final project.
Hafiz Muhammad Ansar
Very nice blog for WordPress help. I recommend for beginners to use this platform. Thankful!
WPBeginner Support
Glad you found our article helpful!
Admin
Abdullah
Amazing, it worked
WPBeginner Support
Glad our guide was helpful!
Admin
Nidhi Gupta
it’s really helpful, thankyou so much
WPBeginner Support
Glad our guide was helpful!
Admin
Habu
Omg you save my life !!! THANK YOU VERY MUCHH !!!
Jahir
I can not log in now same process…any updates?
WPBeginner Support
The most common issue would be if you did not set the function to MD5 or click go to apply the changes, you would want to ensure you have done that correctly.
Admin
Kamondo
Wonderful! problem solved. Very Simple steps but powerful.
WPBeginner Support
Glad our guide was helpful
Admin
Joe
I’m encoutering this problem now after installing the 2nd WordPress on MAMP. This article is very to the point and I’ll try it tomorrow!
WPBeginner Support
We hope the guide helps
Admin
Gerron
Solid solid info right here, thanks a lot, really helped, so simple
WPBeginner Support
Glad our guide was helpful
Admin
Odineks
Thank you so much. I always find solutions to every of my WP problems here.
I kept having problems with the login page on the frontend not recognizing my new password, I didn’t realize there is a function to pass that message to myPHPadmin.
WPBeginner Support
Glad our guide was helpful
Admin
naved ahmed
Thanks a lot. Finally problem solved within a minute.
WPBeginner Support
Glad our guide was helpful
Admin
Mohsin
I just love this
Love the way you write every thing
WPBeginner Support
Thank you, glad you like our content
Admin
Jen
I tried this and while I was in there also attempted to change my username, which I realize was probably my mistake… but now I can’t log in at all. Is there a way to undo what I’ve done?
WPBeginner Support
You would need to follow the steps in the article and that would bring you back to where you could edit, you should also be able to use your email as an alternative
Admin
Justina
Your Blog is always so full of rich articles. Thanks so much. was stuck for a while because I skip the MD5 option. You are a lifesaver.
WPBeginner Support
Glad our guide could be helpful
Admin
Sarah
Thank you SO MUCH for this! You saved me so many more hours of tinkering with trying to figure out how to log in!!
WPBeginner Support
Glad we were able to help
Admin
David
Thank you ever so much! Normally, I keep this stuff handy; but in this case, I did could not find where I wrote the information down.
You saved a total re-work of a site I was planning.
WPBeginner Support
Glad our guide could be helpful
Admin
adeel kamran
You saved me, I had a lot of work there.
WPBeginner Support
Glad our guide could help
Admin
lokesh n
thank you it’s really working thank you
WPBeginner Support
You’re welcome glad our article was helpful
Admin
Vivek
Hi,
When I reset My password through link then what fileds affected in Database and in which table.
Kindly share this information i am waiting for your response.
WPBeginner Support
For understanding the database you would want to take a look at our article here: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-database-management-with-phpmyadmin/
Admin
Adnan Khan
After half an hour of search i just found my help from this site, which solves my problem in no time,
thanks a lot
keep it up guys
WPBeginner Support
You’re welcome, glad our guides can be helpful
Admin
Tenasu Mensah
thanks a lot, kudos to you guys keep the good work doing,you guys are doing great job
WPBeginner Support
Glad our guide could help
Admin
Anuj
It work fine, Thanku so much,
Pádraig
Really simple and great explanation.
Many thanks for sharing.
Saranya
Works Good! Thanks a lot.
Patr
Hello,
I type a new password , click continue and it does not keep the password, it shows a long string of numbers and letters. If I use this , still cannot log in. It looks simple on the video but does not work for me. Thank you.
I looked everywhere on the internet, no solution worling.
Jason
Same problem here. Did you find a solution? Is there any chance of being hacked?
Christian Gochez
when I click on the Go button this error appears:
#1881 – Operation not allowed when innodb_forced_recovery > 0
Edward
Simple and neat! worked thanks
Handel
I started to just reinstall wordpress, but then decided to do a google search, and there was GOOD OLD RELIABLE WpBeginner.com
Thanks a million!!
Sheriff
very effective… kudos
Icholia
Hello
THANKS, Wow there is no other place that you can get well explained information like this , i have been suffering but now i just followed your tutorial and it is a game changer i love you guys and i will always learn from you guys once again thanks
CJ
Thank you! For those who can’t make it work, remember to use the “MD5” function when changing the password. I almost skipped that part and was stuck for a few minutes.
mohamad hossein
so use full thank you so much
Janet
I got completely lost on the video so I tried plugging in the URL. Doesn’t work. Still lost.
Ma
Thanks so much, you saved me from what could have been a very embarrassing situation!
James
I change the password, username, userlogin and nickname not I cant login. Any advice?
suganya
i can’t able to login .because it’s shows me like email is not registered .so what can i do???
Jac
Thanks so much for providing this info – I was really stuck!
Gerhard SCHNEIBEL
Thanks a lot for your help. I am very happy with “wpbeginners”.
Renu
it worked.. thanks a ton..
Anthony
Hi…
I am so thankful for such great information you provide. I have bookmarked your site a while back.
I have been working on a site in wordpress using xampp on the Apache local server. Just recently, I am not able to login on the admin page. I have managed to create a user name and password that works on about 95% of all sites requiring me to register. I also created a file that lists all my login info for everywhere I need to login, including the WP admin login page, IF I ever forget that info.
I have read this page (https://www.wpbeginner.com/wp-tutorials/how-to-reset-wordpress-admin-password-on-localhost/) and watched the video, also. The only problem is that when I click on the wp_users in phpMyadmin, I get this error- ‘#1932 – Table ‘bitnami_wordpress.wp_users’ doesn’t exist in engine.’
Am I reduced to re-installing WordPress, or is there another way around it?
I have tried restoring my computer (using system restore) to various past restore points, but with no luck. Can you help me with this?
I would be so thankful!!! I have put months of work into designing a site to launch, and I HAVE exported everything to a file quite a few times using WordPress import plugin (something like that).
Could you provide a solution?
Thank you so much…
Anthony
WPBeginner Support
Hi Anthony,
you can also add an admin user by adding code to your current WordPress theme’s admin file.
Admin
Kakaire Charles
Extremely wonderful. Thank you for sharing.
Gaurav
i tried this but not working
shaikh muneer
super way to reset admin password thank you for share this