Reset WordPress password using MySQL

0
92
Reset WordPress password using MySQL

When using WordPress, due to some reasons, you might to change or reset WordPress password for administrators or members. This article will show you the easiest way to do it using MySQL.

In order to achieve this using MySQL, you are required to have permissions to access to the database. Certainly, if you are not server administrator of the WordPress sites, you probably cannot do this.

With appropriate permission, you can access MySQL in various ways to execute query statements to reset WordPress password for user.

Table of Contents

Reset WordPress password directly using MySQL

It depends on your server or hosting provider, you can use proper tools to manage MySQL database.

  • If you’re using shared hosting service such as NameCheap, BlueHost, GoDaddy... you can only CPanel and open up the phpMyAdmin.
  • If you have remote SSH access to the server, you can reset WordPress password through MySQL command-line interface.

Okay, so let see how we can reset WordPress password using these tools.

via phpMyAdmin

First is to select appropriate WordPress database you want to change WordPress user passwords, and then click on wp_users table.

Select wp_users table

The interface will list up all user records, click Edit button of the user you want to reset password.

Edit WordPress user

Look at the user_pass field, type the new password into Value column, and then choose MD5 at Function column.

Change WordPress user password

Finally, just clicking on Go button to commit changes to user data.

Basically, what it does is to calculate MD5 hash value of the new password value you put in, then update that to user record, which noted as user_pass attribute in wp_users table.

via MySQL Command-line Interface

If you’re familiar with MySQL CLI, then this should be done easily.

First, you will have to connect to the database with right database users.

$ mysql -u DB_USER -p

You will be asked to input user database password, type it in then press Enter key.

Now, select the correct WordPress database, and look up user credentials to verify first.

mysql> use WORDPRESS_DB;
mysql> SELECT ID, user_login, user_pass FROM wp_users;

You can add WHERE condition to filter users you want to edit password.

mysql> SELECT ID, user_login, user_pass FROM wp_users WHERE user_login = 'kodemate';
+----+-------------+------------------------------------+
| ID | user_login  | user_pass                          |
+----+-------------+------------------------------------+
| 1  | kodemate    | $P$BktYWAcDe35a1nt8c6hVpS52KKxISZ0 |
+----+-------------+------------------------------------+

After identifying user, execute following SQL query to reset user password.

mysql> UPDATE wp_users SET user_pass = MD5('new_password') WHERE ID = 1;

This SQL query first will calculate MD5 hash value of new password value ‘new_password‘ then insert into user_pass field for user with ID = 1. Simple and straight forward!

In conclusion

As you can see from above step-by-step guide, it is pretty much easy to reset WordPress password for users directly using MySQL database.

Depending on your access permission, pick up what method that is appropriate to your situation.

Be aware that in WordPress, both administrators and regular users are stored in wp_users table. Make sure, you update the correct records in database.

Also, take your time to refer to guide on official WordPress for more information.