Reset WordPress User Password Via Shell (SSH)
Oh, snap… you’ve forgotten your WordPress admin password and the other password reset features are for some reason not an option. Lucky for you, there’s a surprisingly easy way to reset any WordPress user’s password using shell (SSH) access to your server, by accessing MySQL directly using a few powerful command line tools…
After you login to your web server via SSH, simply connect to MySQL using the below command:
mysql -u root -p
After you enter the password for MySQL’s root user, specify the database where you’ve installed WordPress (below). We are going to check to verify which users (and tables) exist before resetting our user’s password:
use wordpress
show tables;
After inputting the above set of commands, you should see several tables listed in your SSH window that begin with wp_
if you have a typical default WordPress installation. Specifically, you should also see a wp_users
table in most cases, although the prefix may differ. Next, we want to view the actual list of users in this WordPress installation:
SELECT ID, user_login, user_pass FROM wp_users;
The above command will display a list of the users (accounts) that are part of the given WordPress installation. Be sure to change wp_users
to the appropriate prefix as needed for your installation. Next, make sure you are aware of the ID (number) of the username whose password you want to change, then input the below command (be sure to encode your desired password using a free MD5 generator, otherwise it will not work as the passwords table in WordPress is set to MD5):
UPDATE wp_users SET user_pass="[MD5-string]" WHERE ID = 12345;
To verify that your user password has been successfully changed/updated, re-input the following:
SELECT ID, user_login, user_pass FROM wp_users;
If the MD5 hash code appears properly for your user in the list, you are done! Before exiting MySQL command line, be sure to test your new username/password combination by trying to login via the WordPress admin panel.
exit
Leave a Reply