How To Enter a New Password for WordPress Using Mysql CLI on Linux

See the name of the database used by WP. You can find the database name in the wp-config.php file or you can use the command

grep DB_NAME wp-config.php

We are interested in this line

define( 'DB_NAME', 'wpdatabase' );

Once we find out the name of the database we need to connect to it using the command

mysql -u root -p wpdatabase

Now we need to find the user using a command similar to this, customize as needed

SELECT ID, user_login, user_pass, user_email FROM wp_users;

when we find the user it is easiest to select it using the ID, most often the administrator ID is 1 because it is the first user-created, and the command to enter a new password is as follows

UPDATE wp_users SET user_pass = MD5('my-new-password-here') WHERE ID = 1;

That’s it, try logging in to WP administration.

Related Posts