1. Home
  2. Enhance Panel
  3. WordPress Command Line
  4. How to reset a WordPress admin password with WP-CLI

How to reset a WordPress admin password with WP-CLI

If you’re locked out of your WordPress admin area, WP-CLI can get you back in.

New to WP-CLI? Start with getting started with WP-CLI, which shows you how to connect and get to your website’s folder.

You can also log straight in to WordPress from your Enhance panel without a password – see how to log in to WordPress from your Enhance panel. Once you’re in, you can change your password in WordPress as normal.

Find your username

wp user list --role=administrator --fields=ID,user_login,user_email

This lists your admin users with their username and email address.

Option 1: Send a password reset email

wp user reset-password yourusername

WordPress emails a password reset link to that user’s email address.

Option 2: Set a new password yourself

wp user update yourusername --prompt=user_pass

You’ll be asked to type the new password. Nothing appears on screen as you type – that’s normal. Press Enter when you’re done.

Avoid typing a password directly into a command, for example --user_pass=MyPassword. Commands are saved in your SSH history, so the password could be read later. Using --prompt keeps it out of your history.

Create a new admin user

If you’d rather create a new admin account, for example for a developer:

wp user create newusername [email protected] --role=administrator

WP-CLI creates the user and shows a strong password on screen. Copy it somewhere safe straight away.

Remove a user you no longer need

wp user delete oldusername --reassign=yourusername

The --reassign part gives their posts and pages to another user, so nothing is lost.

If you didn’t expect to be locked out, or you see admin users you don’t recognise, your website may have been compromised. Change all your passwords, remove users you don’t recognise, and contact our support team.

Need a hand? Please contact our support team. We look after your hosting and WP-CLI; problems inside WordPress plugins and themes are covered in do you support WordPress plugins and themes.

Updated on October 1, 2026
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
GET SOME HELP!