Get the WordPress Login PassWord From the CLI Steps
If you forget the WordPress password/you want to change the password from the CLI.
WordPress Login PassWord From the CLI Steps
Step 1:
Login to SSH using root access.
Step 2:
Type the below command to open MySQL/MariaDB in the CLI.
- mysql
Step 3:
- Next, find the Database name and user for the domain you need to reset the password.
- You can find those details under “wp-config.php”
- Copy the Database name in the DB_NAME.
- Now we can assume the DB_NAME as “test_DB”
Step 4:
- Use the command “use name-of-database”
- use test_DB
Step 5:
- Use the below command to view the WordPress table.
- Show tables LIKE ‘%users’;
- Here you can view the WordPress table.
- Now we can assume the table as “test_table”
Step 6:
- Use the below command to view the username and password used in the login page.
- SELECT ID, user_login, user_pass FROM name-of-table-you-found WHERE user_login = ‘username used in login page’;
- Now we can assume the username as “admin”.
- name-of-table-you-found = test_table
- username used in login page = admin
- Use the command as below.
- SELECT ID, user_login, user_pass FROM test_table WHERE user_login = ‘admin’;
Step 7:
- You can use the below command to update the new password for the username.
- UPDATE name-of-table-you-found SET user_pass=MD5(‘new-password’) WHERE user_login = ‘username used in loginpage’;
- name-of-table-you-found = test_table
- username used in loginpage = admin
- new-password = NewPassword@1234
- From the CLI use a simple password such as “NewPassword@1234”
- Once you change the password from the CLI and once you login to the WordPress successfully, set a strong password.
- Use the command as below.
- UPDATE test_table SET user_pass=MD5(‘new-password’) WHERE user_login = ‘admin’;
- Now the password has been successfully updated and changed.
Step 8:
- To confirm if the password has been changed or not.
- Follow the “Step 6”
- Copy the user_pass in a Notepad.
- Check with the old user_pass already copied in the Notepad
- If the values differ then the password has changed.
Step 9:
- Enter the “exit” command (Exits the MySQL client)
Step 10:
Log in to WordPress Login password from the CLI has been altered.
Roshan