How to reset WordPress Admin Password via MySQL Command Line

2020-04-22 By Aaron 4564 Views linux wordpress cms_application
5 reviews

In WordPress, there is more than one way to reset your password if you are using Linux OS. Here is the step to reset the password via the MySQL command line.


Step 1 : Generating MD5 hash for WordPress admin password


  1. Try to change the current password admin123 to wpadmin123.

    Create a file called wp.txt, containing nothing but the new password.

    # vi wp.txt
    

    wppw1

    wppw2

  2. Run the below command to get the MD5 string.

    # tr -d ‘\r\n’ < wp.txt | md5sum | tr -d '-'
    

    wppw3

    Now you will get the MD5 string of the new password wpadmin123 that you have saved in the file wp.txt.

    Please save the MD5 string locally.

  3. Run the below command to remove the file wp.txt.

    # rm -rf wp.txt
    

    wppw4


Step 2 : Updating the admin password through MySQL using the newly generated MD5 hash string


  1. Log in to MySQL with the below command.

    # mysql -u root -p
    

    wppw5

  2. Enter your MySQL password.

    wppw6

  3. Run the below commands to use the WordPress database and show the table name with wp_users. Here we are using the below database and user for testing.

    WordPress DB: wordpress

    WordPress User: wp_user

    > use wordpress;
    
    > show tables;
    

    wppw7

  4. Run the below command to get an idea of what’s going on inside.

    > SELECT ID, user_login, user_pass FROM wp_users;
    

    wppw8

    From here you can see the MD5 string of the current password of the database WordPress.

  5. Now you can reset the password of your WordPress admin with the below command.

    > UPDATE wp_users SET user_pass=('8221bbe0c8e475a295b7533c047a68c7') WHERE user_login = 'admin';
    

    wppw9

    Now check with the below command if the password has changed.

    > SELECT ID, user_login, user_pass FROM wp_users;
    

    wppw10


Related Tutorials

What do you think about this article?

Rate this article
LayerStack Plans

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.