To strengthen the security of your WordPress website, creating and using a strong complex password for your admin account is very critical. But there is one thing I hate about strong and complex passwords, they are easily forgettable. That’s the only risk involved in using complex passwords on your website. So in this article, I will show you a couple of ways to recover or reset your forgotten WordPress admin password. If you run a WordPress website then it’s very essential to keep these tips handy.
In WordPress, there is more than one way to reset the WordPress admin passwords. In normal circumstances, you can do it through the forgot password link on the WordPress login interface. But sometimes, you don’t have that option and have to take different steps to reset your password, especially if you disable forgot password feature.
Here I am listing 2 different ways to reset the WordPress admin password. Any one of them will work, and you only need one to succeed. Which method you will use depends on what type of access you still have to your website.
With FTP
If you have FTP access to your website then you can paste the following code snippet in your theme’s functions.php file. This will change the password of user id 1 with “New Password”. Make sure you change the “New Password” string with your desired password and user ID before you use this code.
// reset forgotten wordpress admin password with functions.php
wp_set_password( 'New Password', 1 );
Please note: This code should be deleted after the first page load, otherwise the password will be reset on every subsequent load, sending the user back to the login screen each time.
With MySQL
If you have phpMyAdmin or MySQL access then you can simply run this MySQL query in your database to reset the password of a user. Before executing this query, change the “New Password” string to your new password and edit the user-login name “admin” and table-prefix value “wp_” if necessary.
// reset forgotten wordpress admin password with mysql
UPDATE wp_users SET user_pass = MD5('New Password') WHERE user_login = "admin";