How To Change WordPress Admin Password and Email from Linux command line

Try it in our public cloud & Get $5 Credit

WordPress’ web-based installer and administrative interface is powerful, letting you perform most essential tasks from the comfort of your browser. Even so, it is easy to render this system difficult or impossible to use in a number of ways. One such is forgetting your administrative password, losing access to your administrative email address, or breaking the server such that it can no longer send outbound email so you can recover lost credentials. If any of these things happens to you, it is possible to change these configuration values directly in the database using the Linux command line.

Getting Started

To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) with any Linux distribution installed.
• WordPress previously installed.

While we’ll work to preserve things should anything go wrong, realize that your login credentials will be changed if you follow these steps, so take appropriate precautions so you can log in later.


Before we begin, let’s back up your WordPress database. These steps should be safe to perform, but having a backup is a good practice to follow before performing any operations on the database layer.

mysqldump -u root -p wpdatabase > /root/wpdatabase.sql

Start by accessing the MySQL console. You’ll be prompted for your MySQL root password.

mysql -u root -p

At the console, access your WordPress database. From this point onward, any commands you send will run on this database.

use wpdatabase;

We’ll now verify your user details to ensure that we know which records to update later.

SELECT ID, user_login, user_pass FROM wp_users;

Next we’ll manually update your administrator password. You can update your email address and password independently, depending on which task you need to perform.

UPDATE `wp_users` SET `user_pass` = MD5('new_password_here') WHERE `wp_users`.`user_login` = "admin";

Now we’ll update your administrative email address. (optional)

UPDATE `wp_users` SET `user_email` = "new@email_address.tld" WHERE `wp_users`.`user_login` = "admin";

At this point you’ve reset your necessary login credentials. You can now successfully log in with the email address and password you’ve just configured.


WordPress’ web interface is usually more than capable. If it ever fails you, though, then it is useful to fall back on the MySQL console to make necessary configuration changes. If this guide was helpful to you, kindly share it with others who may also be interested.