WP-CLI Change Password: Complete Guide

Bulletproof Backups for Your WordPress Website

Fortify your business continuity with foolproof WordPress backups. No data loss, no downtime — just secure, seamless operation.

wp-cli change password

You can use WP-CLI change password commands to quickly reset your WordPress passwords. Whether you’ve forgotten credentials, discovered suspicious activity, or can’t access recovery emails, standard password recovery often fails when you need immediate access most. If you use WP-CLI, you can do this in a few commands. 

When you use WP-CLI, it works directly with your database through the command line, bypassing emails and dashboards entirely. This makes it a sure-fire method for regaining admin access in under 60 seconds, regardless of broken plugins or email issues.

This article will break down the steps and commands you need to follow. You’ll have access to your site in minutes. 

TL;DR: SSH into your server, navigate to your WordPress directory, then run the wp user update command. You’ll be prompted to enter the new password without it showing in your command history. 

Before You Use WP-CLI Change Password

Before diving into password resets, ensure you have the necessary server access and tools in place. These prerequisites are essential for using WP-CLI commands safely and effectively on your WordPress site.

  • SSH Access: Depending on which web host you use, they may provide SSH access through their control panels. But you may need to enable it manually or contact support if it’s restricted. Have your server’s IP, username, and your password or SSH key ready.
  • Verify that WP-CLI is installed: After SSH, run wp –info to check if WP-CLI is installed. If you get information about the PHP version or the WordPress installation, you’re all set. 
  • Take a backup: Create a backup with WP-CLI. This is important so that you can restore it quickly, if things go wrong.

How to Change Password Using WP-CLI

Changing a WordPress password through WP-CLI is the fastest and most reliable method when you need immediate admin access. This command-line approach bypasses all the usual roadblocks. There are two different ways to do so:

Option 1: Secure WP-CLI change password method (Recommended)

Protecting your login credentials is paramount to WordPress security. The secure method uses interactive prompts to ensure your password never appears in your command history.

  1. Connect to your server using SSH: Connect to your server using a terminal or SSH client to access the command line interface.
ssh username@your_server_ip

Replace username with your server username and your_server_ip with your actual server IP address. You’ll be prompted to enter your server password.

  1. Locate Your WordPress Install: Navigate to your WordPress root directory where the wp-config.php file is located.
cd /var/www/html/your_site
  1. List All WordPress Users: Display all WordPress users to identify the account you need to update.
wp user list

The command lists all users with their IDs, usernames, emails, and roles. Note the username or ID of the account you want to reset.

  1. Reset the Password Securely: Use the command wp user update to change your user’s password
wp user update userID --prompt=user_pass

Replace userID with the actual username or ID number from the previous step. The –prompt=user_pass flag ensures your password won’t be saved in command history.

  1. Enter Your New Password: Type your new password when prompted. Press Enter. You’ll see a prompt asking for the new password. Type your desired password and press Enter. You will need to confirm it by typing it again. The password won’t be visible on screen for security.

You’ll receive a success message confirming the password change.

Option 2: Direct WP-CLI change password method (Use with Caution)

The direct method allows you to reset your password immediately within the command itself. It makes it faster but less secure. Use this method only on a private server or in emergencies

  1. Connect to Your Server: Access your server using SSH from your terminal or SSH client.
ssh username@your_server_ip

Enter your server password when prompted to establish the connection.

  1. Navigate to WordPress Directory

Move to your WordPress installation folder.

cd /var/www/html/your_site

Replace /var/www/html/your_site with your actual WordPress directory path.

  1. Run the Direct Update Command

Execute the wp user update command with your new password included.

wp user update userID --user_pass="YourNewPassword123!"

Replace userID with the actual username or ID number, and YourNewPassword123! with your desired password. Keep the password in quotes to handle special characters.

Press Enter to execute,

wp-cli change password

The command runs without prompts and updates the user’s password directly in the WordPress database. Look for the confirmation message from WP-CLI. You’ll see “Success: Updated user [ID]” confirming the password has been updated. 

⚠️ WARNING ⚠️
Most shells, like bash or zsh, record every command in history files (such as ~/.bash_history). This means that anyone with server access can later view your password in plain text. This will open a whole new breach in login security

Troubleshooting Common WP-CLI Change Password Issues Issues

Even with the correct commands, you might encounter errors when resetting WordPress passwords via WP-CLI. These issues typically stem from directory problems, file permission conflicts, or caching interference. Here are the most common problems and their quick fixes to get your password reset back on track.

“Error: This does not seem to be a WordPress installation”

WP-CLI shows this when it can’t find WordPress files in the current directory.

ls -la

Run this command to list all files in your current directory and verify that wp-config.php exists. If you don’t see WordPress core files, navigate to the correct directory using cd /path/to/your/wordpress/folder before running WP-CLI commands.

“Permission Denied” Errors

Permission issues happen when your user account lacks the necessary rights to modify WordPress files.

sudo -u www-data wp user update admin --prompt=user_pass

Run the command as the web server user (usually www-data or nginx) to bypass permission restrictions. This ensures WP-CLI has the proper file system access to update user data in the WordPress database.

Password Still Not Working After Reset?

WordPress cache can prevent your new password from taking effect immediately. Clear any active caching plugins like W3 Total Cache, WP Rocket, or WP Super Cache from your WordPress admin panel. Also check CDN services like Cloudflare and purge their cache, as they may be serving cached login pages that don’t recognize your new credentials.

Alternative Methods To Change Your WordPress Password

When WP-CLI isn’t available or SSH access is restricted,  there are other ways. Here are the top three ways to do so:

  1. Change Password Using the Login Page: The simplest method is to click “Lost your password?” Enter your username or email address to receive a password reset link via email. This standard method works best when your site’s email functionality is working properly and you have access to the associated email account.
  2. Login Using an External Dashboard Like BlogVault: Click the WP-ADMIN button on the BlogVault dashboard. This bypasses local login issues entirely, allowing you to change passwords, update plugins, and perform maintenance tasks even when your main site is experiencing authentication problems.
  3. Reset via Database: Access phpMyAdmin through your hosting control panel, and navigate to your WordPress database.Replace the user_pass field with the MD5 hash of your new password. This method requires database access but works when all other options fail.
  4. Restore your site: If you got logged out suddenly (because of a hack, for example), revert your entire site to a pre-lockout state. After that, figure out what happened and deal with it accordingly. 

Final Thoughts

As someone who’s constantly testing plugins and features for our articles, I’ve gotten locked out a lot. I’ve always been grateful that I can regain access instantly using the BlogVault dashboard. Having that external access point has saved me countless hours of frustration and kept projects on track when local login methods failed. 

However, if I didn’t have BlogVault’s safety net, WP-CLI would absolutely be my go-to solution for emergency access. The ability to reset passwords directly through the command line, without relying on email systems or functional dashboards, makes it an invaluable tool for any serious WordPress user. 

FAQs

What is WP-CLI?

WP-CLI is a command-line interface for WordPress that allows you to manage your site directly from your server’s terminal. It’s an official tool that lets you perform WordPress tasks like updating plugins, managing users, and resetting passwords without accessing the admin dashboard. Most hosting providers pre-install WP-CLI, making it available whenever you have SSH access to your server.

How to change WP user password?

Use the WP-CLI command wp user update username –prompt=user_pass for the most secure method. First, SSH into your server, navigate to your WordPress directory, then run wp user list to find the username or ID. Finally, execute the update command and enter your new password when prompted. This entire process takes under 60 seconds.

I’m not receiving my change password email. What to do?

When WordPress password reset emails aren’t arriving, WP-CLI offers the fastest alternative solution. Email issues often stem from server configuration problems, spam filters, or broken SMTP settings. Instead of troubleshooting email delivery, bypass it entirely by using the WP-CLI method above, or access your site through BlogVault’s dashboard if you have it connected.

How to use WordPress database to change passwords?

Access phpMyAdmin through your hosting control panel, locate your WordPress database, and find the wp_users table. Click “Edit” on the user you want to update, then replace the user_pass field value with the MD5 hash of your new password. Save the changes and your new password will be active immediately. This method requires database access but works when other options fail.

What is the MD5 hash?

MD5 is an encryption method that converts your plain text password into a scrambled string that WordPress can safely store in the database. For example, the password “mypassword123” becomes “482c811da5d5b4bc6d497ffa98491e38” when MD5 hashed. You can generate MD5 hashes using online tools or by running echo -n “yourpassword” | md5sum in your terminal before adding it to the database.

Tags:

You may also like


learndash vs tutor lms
LearnDash vs Tutor LMS: Which Should You Choose?

Stuck choosing a platform for your online course? The LearnDash vs Tutor LMS debate is a critical decision for any creator. Picking the right one means a smooth launch and…

learndash vs learnpress
Learndash vs LearnPress: Which One Should You Choose?

Your search for Learndash vs LearnPress ends here. This single decision impacts your budget, your students’ experience, and your ability to scale. Picking the wrong plugin means hitting a wall…

How do you update and backup your website?

Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.

Updating Everything Manually?

But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.

Backup Your WordPress Site

Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.