It can happen that you forget your WordPress administration login password.
If this ever happens to you, here is a step-by-step guide on how to change your password. You can do it from your database or from the command line.
Change Password From Database
To change the password with phpMyAdmin:
- Open phpMyAdmin (how).
- Select the database associated with your WordPress:
- Click on the wp_users table (the prefix may be different from wp, depending on how your WordPress has been configured):
- Locate your administrator username, and click on the Edit button next to it:
- Set the new password. To do so, proceed as follows:
- locate the user_pass field;
- choose MD5 from the drop-down list under the Function column;
- enter your new password in the text field under the Value column; and
- click on the Go button at the bottom of the window.
Changing the Password From the Command Line in MySQL
To access your WordPress database via the MySQL command line, you need to know your database credentials. These credentials are usually stored in the wp-config.php file, which is located in the root directory of your WordPress installation.
Here are the steps to follow:
- Connect to your server via SSH (how) and enter the MySQL command line using your database credentials.
- Use the following command, replacing user with your user, then enter your main account password when prompted:
mysql -u user -p
- Select your WordPress database by executing the following command line query (replace wordpress_db with the name of your database):
USE wordpress_db;
- Make a SELECT to be sure to modify the right row:
SELECT * FROM wp_users WHERE user_login = 'user';
- Run the following query to change your password (replace new_password with the desired password, and user with your administrator username):
UPDATE wp_users SET user_pass = MD5('new_password') WHERE user_login = 'user';