3 Ways to Reset Your WordPress Admin Password on Localhost

Most of the WordPress users install WordPress on localhost to test their application, develop And test themes and plugins. Sometimes you may forget the admin password of your local installation. In this tutorial, I am going to show how you can reset WordPress admin password on localhost.

In the live environment, you can reset your WordPress password by simply clicking Lost your password? Link on your login page. Then you will get an E-mail contains the link to reset the password.

But This method doesn’t work on the local environment because mail function turned off by default in the local server. But don’t be panic. There are multiple ways to reset WordPress password on localhost.

1. Reset WordPress Admin Password on Localhost Using phpMyAdmin

Here I am using phpMyAdmin to reset WordPress Admin password. This method is very simple as compared to other methods.

Step 1: Navigate to Localhost on your browser by typing http://localhost on your browser

Step 2: Click on phpmyadmin link. Then you will be redirected to phpMyAdmin control panel login page.

Step 3: Enter your Username and Password associated with that WordPress database and hit go. If you haven’t created a separate User account for that database or don’t know the username and password of phpMyAdmin, use root as username and blank password.

phpmyadmin-login-page

Step 4: Now select the database associated with your WordPress installation.

Step 5: Once you selected the database, you will see the list of tables available in your database.

Step 6: Now Select The wp_users Table. It will display the list of user and their hashed password, email address etc., in your wp_users Table. Now click on the pencil icon to edit that table.

Step 7: Look for the user_pass row, select MD5 from the function dropdown list and type the new password in the value field and click Go.

reset wordpress password on localhost from phpmyadmin

That’s it. You have successfully changed the password of WordPress admin on localhost using phpMyAdmin.

2. Reset WordPress Admin Password on Localhost Using MySQL Command Prompt

To reset WordPress Admin password using MySQL Command prompt, first of all, you need to launch the MySQL CMD.

Step 1: Launch MySQL CMD by clicking WAMP Icon -> MySQL -> MySQL Console.

starting mysql commandline

Step 2: Now the console window asks you to enter the password. Enter your password and hit Enter key.

Step 3: Now you have access to MySQL Command Prompt, which was indicated by “mysql>”. Now enter the following commands to reset your password.

Step 4: enter the following command to access your database. In this case, my database name is demosite, you can replace it with your database name.

use demosite;

Step 5: Now enter the following command to display the user id, user name and hashed password from wp_users table.

SELECT ID, user_login, user_pass FROM wp_users;

Step 6: Now enter the following command to change the password of WordPress user with ID=1 in wp_users table.

UPDATE wp_users SET user_pass = MD5(‘MyNewPassword’) WHERE ID=1;

Step 7: Awesome, you have successfully changed your WordPress admin password from MySQL Command Prompt on Localhost. now you can exit MySQL Command Prompt by using the exit command.

Exit;

reset wordpress password on local host using mysql command line

3. Reset WordPress Admin Password on Localhost Using functions.php file

This is my favorite way to reset password coz of its simplicity :P. In This method of resetting WordPress password, you need to modify the active theme’s functions.php file.

Step 1: Navigate to the directory of the active theme in windows explorer. In my case, the active theme is TwentySixteen Theme. The themes folder should be found in wp-content\themes\YourActiveThemeFolder.

Step 2: open the functions.php file in your favorite code editor.

Step 3: Add the following line of code in line next to the first <?php line and hit save button. Replace the MyNewPassword with the password whatever you want.

wp_set_password(' MyNewPassword ',1);

 

reset wordpress password from theme functions php 1

In the above code, 1 is the user id of the WordPress user you would like to reset the password. Here we are going to reset password admin user. For the default administrator account which you have created during installation, user id is always 1. So I have added 1 in that code.

Step 4: Now navigate to the WordPress login page of your site in the web browser and enter the username and your chosen password and hit login. once you click the login button, if your entered password and the password which you have used in functions.php file matches, then the password will be updated in the database table.

Note: Hitting login button doesn’t redirect you to WordPress dashboard.

Step 5: Now open the functions.php file and remove the code which you have added earlier in step 3 and save the file.

Step 6: Now login to your WordPress site and enjoy.

I hope this article helped you to reset WordPress admin password on localhost. if you have questions or still facing problem to reset the password, ask me in the comment section.

I am Divakara Ganesh, Heart and Soul of WPEra. I am a blogging addict, WordPress and Genesis Framework lover, web developer. Apart from blogging, I love to listen music and watch movies.

Leave a Comment