Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Reset WordPress Admin Password on Localhost

Forgetting your WordPress admin password on localhost can be frustrating. Since email recovery might not work in this environment, you will need other ways to regain access.

We recommend installing WordPress locally on your computer to learn WordPress development or testing new plugins and themes.

However, several things don’t work on localhost as they would on a live site. This includes email functionality, which you will need for resetting your password.

In this guide, we will show you several easy methods to reset your WordPress admin password on localhost.

Resetting the admin password in WordPress on localhost

Why Resetting the Password Doesn’t Work on Localhost

The term localhost means a local server that is unavailable to the general public, such as your personal computer.

Many WordPress users install WordPress on localhost (on their computer) to test changes, design websites, try out new plugins, and even learn WordPress.

If you haven’t tried it, the following tutorials will help you install WordPress on your computer:

  1. Install WordPress locally on Windows
  2. Install WordPress locally on Mac

Now, here is the problem that some beginners may come across.

If you forget your WordPress admin password while working on localhost, then you cannot reset it using the normal password reset option in WordPress.

The password reset option emails you a link to reset your WordPress password. Your server needs to enable the mail function to send emails.

But this function is turned off by default on local servers, meaning WordPress cannot send the password reset email.

Don’t worry. There are easy ways to reset your WordPress password on localhost. Here are the methods we will cover in this tutorial:

Method 1. Reset WordPress Admin Password on Localhost Using phpMyAdmin

We will show you how to set the WordPress admin password on localhost using phpMyAdmin for this method. phpMyAdmin is a web-based app that provides a graphical user interface for managing MySQL databases.

Note: phpMyAdmin comes pre-installed on local server packages provided by Wampserver, XAMPP, and MAMP. However, if you are using ‘Local,’ then you will find a different tool called Adminer under the Database tab. It is similar to the phpMyAdmin, and you can follow the tutorial easily.

Adminer the phyMyAdmin alternative in LocalWP

Simply visit the phpMyAdmin control panel by typing this URL into your browser’s address bar:

http://localhost/phpmyadmin/

Note: You may be asked to enter your root username and password to log in to phpMyAdmin. Typically, the username is root with no password.

Once you are logged in, click on your WordPress database in the left column.

Open your database in phpMyAdmin

Once you select your database, you will see a list of tables in it.

Go ahead and click on the browse link next to the ‘users’ table. By default, WordPress uses wp_ for the table prefix, but if you changed it during installation, your database will have a different table prefix.

Open users table in WordPress database

You will now see the list of entries in the ‘users’ table. The number of rows depends on how many users are registered on your WordPress site.

Next, you need to click on the ‘Edit’ link next to the admin user’s username.

Edit user in WordPress database

This will open up a form showing information stored in your WordPress database for that user account.

Scroll down to the ‘user_pass’ field and type a new password in the ‘Value’ column. Then, select MD5 in the ‘function’ column.

Add new user password

The MD5 function encrypts your WordPress password using the MD5 hashing algorithm.

Don’t forget to click the ‘Go’ button at the bottom to save your changes.

Save database changes

That’s all. Using the new password, you can now log in to your WordPress site on localhost.

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.

Locating your theme folder

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');

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 4: 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.

Simply open the functions.php file and delete the code you added earlier. Don’t forget to save your changes.

Bonus Resources:

The following are additional tips and tutorials on managing passwords and admin accounts in WordPress:

We hope this article helped you reset your WordPress admin password on a local server. You may also want to see our tutorial on enabling WordPress emails from localhost with SMTP or take a look at creating a staging site for 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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

64 CommentsLeave a Reply

  1. meli

    thank you sooooo much! I was panicking and I was working on my final project.

  2. 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

  3. Abdullah

    Amazing, it worked

    • WPBeginner Support

      Glad our guide was helpful!

      Admin

  4. Nidhi Gupta

    it’s really helpful, thankyou so much

    • WPBeginner Support

      Glad our guide was helpful!

      Admin

  5. Habu

    Omg you save my life !!! THANK YOU VERY MUCHH !!!

  6. 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

  7. Kamondo

    Wonderful! problem solved. Very Simple steps but powerful.

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  8. 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

  9. Gerron

    Solid solid info right here, thanks a lot, really helped, so simple

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  10. 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

  11. naved ahmed

    Thanks a lot. Finally problem solved within a minute.

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  12. Mohsin

    I just love this
    Love the way you write every thing

    • WPBeginner Support

      Thank you, glad you like our content :)

      Admin

  13. 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

  14. 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

  15. 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

  16. 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

  17. adeel kamran

    You saved me, I had a lot of work there.

    • WPBeginner Support

      Glad our guide could help :)

      Admin

  18. lokesh n

    thank you it’s really working thank you

    • WPBeginner Support

      You’re welcome glad our article was helpful :)

      Admin

  19. 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.

  20. 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

  21. 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

  22. Anuj

    It work fine, Thanku so much,

  23. Pádraig

    Really simple and great explanation.

    Many thanks for sharing.

  24. Saranya

    Works Good! Thanks a lot.

  25. 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?

  26. Christian Gochez

    when I click on the Go button this error appears:

    #1881 – Operation not allowed when innodb_forced_recovery > 0

  27. Edward

    Simple and neat! worked thanks

  28. 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!!

  29. Sheriff

    very effective… kudos

  30. 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

  31. 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.

  32. mohamad hossein

    so use full thank you so much

  33. Janet

    I got completely lost on the video so I tried plugging in the URL. Doesn’t work. Still lost.

  34. Ma

    Thanks so much, you saved me from what could have been a very embarrassing situation!

  35. 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???

  36. Jac

    Thanks so much for providing this info – I was really stuck!

  37. Gerhard SCHNEIBEL

    Thanks a lot for your help. I am very happy with “wpbeginners”.

  38. Renu

    it worked.. thanks a ton..

  39. 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

  40. Kakaire Charles

    Extremely wonderful. Thank you for sharing.

  41. Gaurav

    i tried this but not working

  42. shaikh muneer

    super way to reset admin password thank you for share this

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.