X

Reset a WordPress Password with MySQL

This is how to reset a WordPress password through ssh/command line on a Linux server using the MySQL client. This same practice could be executed via PHPMyAdmin or another web based MySQL tool. WordPress stores the passwords in a one-way encryption hash (md5).

To start this process you need to login to the server via ssh or on the console.

WordPress Password Hash Generation

First create a md5 hash of the new password by piping the new password into md5sum:

[user@server]$ echo -n "newpassword"|md5sum
5e9d11a14ad1c8dd77e98ef9b53fd1ba -

Save the output for later.
Alternatively, you can use any number of online md5 hash generators.

If you do not know the database being used, you will need to ssh to the server that needs to have it reset and go to the WordPress install. You can find the database name in the wp-config.php file.

[user@server]$ grep -E 'DB_NAME' wp-config.php
define('DB_NAME', 'wordpress_db');

MySQL Query to Update WordPress Database

Access the MySQL client on the command line and insert the new password for the user, change out the md5 has for the one you selected as well as admin with the username you are updating the password for.

mysql -e "UPDATE wordpress_db.wp_users SET user_pass = '5e9d11a14ad1c8dd77e98ef9b53fd1ba' WHERE user_login = 'admin';"

If this was to be done in PHPMyADmin, you would just update the row of the user in wp_users with the new password hash.

 

LinuxAdmin.io
0 0 votes
Article Rating
LinuxAdmin.io:
Related Post