If you need to change a WordPress user's passwords but are unable to log into the WordPress dashboard, there are multiple ways you can set a new password.
Choose the method below that's easiest for you.
To set a new WordPress password using the WP-CLI, SSH into your server as the app's system user and change directory to your app's public directory.
Run the following command. Replace USERNAME with the name of your WordPress account. Replace NEW_PASSWORD_HERE with the new password you've chosen.
wp user update USERNAME --user_pass="NEW_PASSWORD_HERE"
The WordPress user's password has now been changed.
To set a new WordPress password using an SFTP client, SFTP in to your server and navigate to your active theme's directory.
Next, open functions.php and add the following line after the first
line in the file (that is, add the following line after the line that says
Replace NEW_PASSWORD with the new password you've chosen.
wp_set_password( 'NEW_PASSWORD', 1 );
If there is more than one WordPress user account, change the number 1 to the ID of the user. If you're unsure of the ID of the WordPress user, you can use the wp command to list users.
Save functions.php back to your server.
You will now be able to log into WordPress with the new password.
After you've verified you can log in with the new password, edit functions.php and remove the new line you'd added.