How to reset the WordPress password using PHP or MySQL

How to reset the WordPress password using PHP or MySQL



How to reset the WordPress password using PHP or MySQL

Tuesday December 18, 2018 Gilblas Ngunte Possi
This article shows how to reset the WordPress password without using the normal process. In fact, in some worst scénerios, it comes a time when you are not able to reset your password. Most of the time, it is either because the mailing server stops responding or the STMP stopped working. If you ever found yourself log out of your WordPress admin without knowing how to reset the password, this article is for you. Otherwise, you can continue reading for your records or curiosity.

The normal process to reset the WordPress password

Just like any other platform or CMS, resetting the password on WordPress is straightforward. In order to achieve that, follow these steps
  • First of all, go to your WordPress login page and click on "Reset Password"
  • Secondly, you will be asked to enter your username or email address. And then, if the system detects an account associated with the email that you enter, you will receive a link to your mailbox. If the system confirmed that an email has been sent and you didn't receive it, you can check your Spam. In the case it is not in your spam, the second section of the article will help to force a reset.
  • Finally, click on the link and enter a new password.

Access account with MYSQL

If you decide to use MySQL query to access your admin, I am assuming that the previous method didn't work. The use of MySQL really, simple. There are two alternatives.

You have access to PHPMyAdmin or database.

For instance, if you can access that your database, all you will need to do is to copy and paste the query below to the console of your database. (Note that you should replace "password" by the new password and 'username'  by your username. Furthermore, you need you might have to replace wp_ in front of "wp_users" by the prefix used by your database. [code] UPDATE `wp_users` SET `user_pass`= MD5('password') WHERE `user_login`='username'; [/code]

You don't have access to PHPMyAdmin but you can use FTP

If you are not able to access your database, you can use the fonctions.php file within your current theme to reset the password. In order to achieve that, these are the steps to follow:
  •  Login to your site via FTP and download your active theme's functions.php file.
  • Edit the file and add this code to it, right at the beginning, after the first
[code] <?php wp_set_password( 'password', 1 ); ?> [/code] Put in your own new password for the main
  • admin user. The "1" is the user ID number in the wp_users table.
  • Upload the modified file back to your site.
  • After you then are able to log in, make sure to go back and remove that code. It will reset your password on every page load until you do.
If you want to have all the different options on how to reset your WordPress Password, please read this documentation from You can also feel free to contact us with any question you may have. Image credit: pixaybay Recommended reading: Few Tips To Improve The Website Performance - WordPress
Stay Updated

Get the latest updates and offers.