Resetting the WordPress admin password using Linux or Unix MySQL CLI


Sometimes, the WordPress user forgets there login credentials especially the password. The WordPress user can change their password easily via the “Lost password”. You can also reset the new password by creating the MD5 Hash.

On our server management plans, our experts will help you in resetting the WordPress admin password using the Linux or Unix MySQL CLI. You can check with our team at any time for emergency support.

Follow the steps to reset the WordPress password wp cli.

Recovering the password by using the MySQL CMD that takes lesser steps.

First, you need to log in as root server by using the SSh command.

ssh [email protected]

Later, find the MySQL version.

mysql --version

You can use the latest stable version.

/usr/sbin/mysqld Ver 8.0.23 for Linux on x86_64 (MySQL Community Server - GPL)

You will get the WordPress database name from the wp-config.php

Grep DB­_NAME wp-config.php


define( ‘DB_NAME’, ‘examplewp’ );

Run the MySQL client as

Mysql –u root –p examplewp

Enter password:  


Run “show tables command” to display the table list. Try to note the table name that ends with _users.

| Tables_in_examplewp  |
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_thesis_backups     |
| wp_usermeta           |
| wp_users              |
13 rows in set (0.00 sec)

From the WordPress get the list of user that has been stored and note the ID.

SELECT ID, user_login, user_pass, user_email FROM wp_users;

| ID | user_login | user_pass                          | user_email              |
|  1 | vadmin     | $P$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy | [email protected] |
1 row in set (0.00 sec)

By following the commands reset the WordPress user password. This will replace the existing password with the new one.

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

We can see a confirmation on the screen:

Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Later, exit from the MySQL session.
Mysql > \q

Before resetting the password we need to install the wp-cli

Installing the wp-cli

Before you start installing the WP-CLI, ensure that you will meet the minimum requirements. Then start downloading the wp-cli.phar file.

PHP 5.6 or later

WordPress 3.7 or later

Unix, Linux, FreeBSD, Cygwin like environment.

curl -O

check and verify whether the phar file is working.

php wp-cli.phar --info

Try to executive and move the files to any suitable PATH.

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Once the installation is done, you can run the following commands wp–info it displays the screen as shown below.

$ wp --info
OS: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /usr/local/bin/php
PHP version: 7.0.22
php.ini used: /etc/local/etc/php/7.0/php.ini
WP-CLI root dir: /home/wp-cli/.wp-cli/vendor/wp-cli/wp-cli
WP-CLI vendor dir: /home/wp-cli/.wp-cli/vendor
WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/
WP-CLI global config: /home/wp-cli/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.4.0

Updating the WP-CLI 

If suppose the WP-CLI is owned by any other system user, for that you need to run the following commands.

sudo wp cli update

Resetting WordPress password with following commands.

## Grab it ##
curl -O
## Make sure it is working ##
php wp-cli.phar --info
## Switch to your webserver user ##
su - wwwuser
 # OR #
sudo -u wwwuser -i
chmod +x wp-cli.phar
## Get a list of users ##
./wp-cli.phar --path=/http/public user list
## Set up a new password for user ID number 1 ##
./wp-cli.phar --path=/http/public user update 1 --user_pass=NEW_PASSWORD_HERE
## Remove wp-cli if you are not going to use it again (optional) ##
rm wp-cli.phar
## Get back to our root shell ##

Test it

Try to login



From this blog, you will get an apparent view regarding how to reset the WordPress administrator password via the MySQL command prompt. Get assistance from expert team support.


More Posts

How to install FFmpeg on centos 8

                  The FFmpeg is a free and open-source solution that collect tools to handle multiple-media such as record, convert, stream audio and video. With the

Send Us A Message

Prevent your Website/Server from Downtimes

Get our experts to manage your server with weekly auditing and 24/7 monitoring