When we can’t access our control panel because we forgot our password or it was changed by someone else, it’s good to have alternative ways to change the password. There is Multiple methods to reset or change a password for your user to login to WordPress dashboard. These are ‘Lost your password?’ link on login page, automatic email sender, FTP and more. there is even two different ways to change password only via phpMyAdmini.e. using a MySQL command line and editing the “users” table in the phpMyAdmin options. In this article, we will cover both methods to change user password from database.
Accessing Your Database
To start editing anything, we will naturally need to access it first. With access databaseif you are working on a live server, contact your hosting provider or access your cPanel and go to phpMyAdmin.
If you are working on a local server, you can go to the designated clipboard for this, we will use the XAMPP control panel and Press the admin button for MySQL.
After doing any of these you will be redirected to the phpMyAdmin control panel page in your default browser.
On the left side of the page, you will see a list of your databases. Select you are trying to login just by clicking on it. After selecting the database you want to edit, see table overview. What you need to do to change a user’s password access the ‘users’ table.
Don’t be discouraged if the tables have a different prefix. WordPress sets wp_ by default, but there are several ways to change this table prefix in your database.
Now the important part, when it comes to changing password, select the ‘users’ table by clicking its name or the Browse link on that row.
You should be taken to the ‘users’ table overview, which looks like this:
If your website has more users, naturally there will be more rows in the table.
The password column can be can be edited from here simply by double clicking on the fieldhowever, this represents an encoded version of the password, and if you typed “4dm1n” for example, the browser will not recognize it as the same password.
The next steps to change the password will depend on whether you want to use the SQL code via the MySQL command line to change the tables or if you prefer to do this manually via the phpMyAdmin data table options.
Resetting WordPress Password Using MySQL Command Line
Now that you are in the database you want to edit and its “users” table, click on the SQL tab shown at the top of the browser window.
A new form should be presented with a text field where you can. replace existing line of code:
SELECT * FROM `wp_users` WHERE 1
with the following line of code
UPDATE `wp_users` SET `user_pass`= MD5('yourpassword') WHERE `user_login`='yourusername';
Please make sure to back up your database before continuing, as a mistake in the code may cause an unexpected database error. Also, make sure leave the single quotes as in the code example above, otherwise the code will not work. Finally, please make sure leave the password in the MD5 brackets Since the MD5 setting uses one of WordPress’ early encoding algorithms that have been changed since then, so when you first try to login to WordPress, it will use a newer encryption algorithm on the password you entered, preserving it to use it as if it were you. You set it up from the WordPress registration page.
Now, after replacing your ‘username’ with the username of the user whose password you are changing and your ‘password’ with the password you want to use in the future, click the GO button in the lower right corner.
When this code is run, it will search for the username you entered in the “users” table and replace that user’s password with the one you chose. If this operation is successful you should see a green bar near the top of the screen specifies that exactly one row is affected by this operation.
Now you can go to your login page and use the newly changed password for the “administrator” user in this example.
How to Reset WordPress Admin Password from phpMyAdmin
However, if you want to change the password manually, Find the user whose password you want to change and click the edit link next to the pencil icon.
After doing that, a form will appear that will allow you to set and edit various user related fields. One of these the user_pass field we will look for to edit.
As you can see in the picture above, we have Changed the value of the function dropdown in the user_pass line to MD5. Then we we add the password we want to use to access the clipboard in the text field next to it.
The reason we had to change the function dropdown is precisely because of the password encoding we talked about earlier. As mentioned earlier, the MD5 setting uses one of WordPress’ early encoding algorithms that have been modified since then, so the first time you try to login to WordPress, it uses a newer encryption algorithm on the password you entered and protects that algorithm for use. If you set it up from the WordPress registration page.
final thoughts
This completes the steps to change your password via phpMyAdmin and using the SQL code within the database. We hope that by using this guide, you will be able to regain control over your setup and not waste precious hours spent setting up your website.