How to reset WordPress password using MySQL CLI

How to reset WordPress password using MySQL CLI

To reset a WordPress password using the MySQL command line interface (CLI), you will need to:

  1. Connect to the MySQL database server:
refer to‮:‬lautturi.com
mysql -u username -p

Replace username with the MySQL username you want to use to connect to the database. You will be prompted for the password for this user.

  1. Select the WordPress database:
USE databasename;

Replace databasename with the name of the WordPress database.

  1. Find the user whose password you want to reset:
SELECT * FROM wp_users WHERE user_login='username';

Replace username with the username of the user whose password you want to reset. This will display the user's record in the wp_users table.

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

Replace newpassword with the new password that you want to set for the user, and username with the username of the user whose password you are resetting.

  1. Quit the MySQL CLI:
quit;

The password for the specified user will now be reset to the new password. You can log in to WordPress using the new password.

Keep in mind that this process assumes that your WordPress installation is using the default database prefix (wp_) and that you know the name of the WordPress database. If your installation is using a different database prefix or if you are not sure of the name of the WordPress database, you will need to modify the commands accordingly.

Created Time:2017-10-29 22:08:36  Author:lautturi