45

wp-cli is great. But it's not clear how I can quickly change a user password with it.

How to change a user's password programatically can probably help to figure this out.

Although wp user update username --field=password is not gonna cut it, apparently md5 is deprecated so it should go through wp_set_password.

4 Answers 4

55

This does the trick:

wp user update USERNAME --user_pass="PASSWORD"

(Found it here.)

2
  • 3
    Hmmm, that's the example used on the wp user update page in the wp-cli docs.
    – Pat J
    Jun 30, 2015 at 15:34
  • 5
    Security Pointer: Add a space in front of this command to make sure you're not including a plaintext password in your bash history. Sep 17, 2020 at 13:36
21

first check the user name:

wp user list

then change password without leaving traces in history

wp user update admin --prompt=user_pass
1
  • 3
    Leaving a space before the command will ensure it is not added to the bash history if someone requires something non-interactive. Sep 17, 2020 at 13:39
3

Just to append one minor thing; sometimes the password may start with the = character. I prefer using this notation, just because of that.

wp user update USERNAME --user_pass="PASSWORD"
0

I have found that sudo definitely changes the path, so I have tried using --allow-root without sudo and the commands work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.