How to reset WordPress password using MySQL CLI

You can reset a WordPress password using the MySQL command-line interface (CLI) by following these steps:

  1. Log in to the MySQL CLI as the root user:
mysql -u root -p

You will be prompted to enter the root password.

  1. Select the WordPress database:
use databasename;

Replace “databasename” with the actual name of your WordPress database.

  1. Update the user’s password:
UPDATE wp_users SET user_pass = MD5('newpassword') WHERE user_login = 'username';

Replace “newpassword” with the desired new password, and “username” with the username of the user whose password you want to reset.

  1. Exit the MySQL CLI:
exit;

Please note that the above SQL statement assumes you are using the default prefix “wp_” for your WordPress tables. If you are using a different prefix, you should replace “wp_” with the prefix you are using in your WordPress installation. Also note that the MD5 is an encryption method and it’s not recommended to use it as it’s not secure. You can use the wp_set_password function from WordPress to reset the password securely.

UPDATE wp_users SET user_pass = wp_set_password('newpassword') WHERE user_login = 'username';

This will reset the password and encrypt it with the latest encryption method that WordPress uses.

Leave a Comment