Uncategorised

Resetting your WordPress password through MySQL/MariaDB Command Line

  1. Login to you database server.
    mysql -u root -p
  2. Select your WordPress database
    USE <name of WordPress database>;
    
    e.g.
    USE wordpress;
  3. Show the tables and look for the table where it ends with “users”.
    SHOW TABLES;
  4. List the contents of the users table or find the username you want to reset. Take note of the users’ current password hash.
    SELECT user_login, user_pass FROM <users table>;
    
    e.g.
    SELECT user_login, user_pass FROM wp_users;
    
    
    SELECT user_login, user_pass FROM <users table> WHERE user_login LIKE '%<search string>%';
    
    e.g.
    SELECT user_login, user_pass FROM wp_users WHERE user_login LIKE '%admin%';
  5. Update the password of the user you like to reset.
    UPDATE <users table> SET user_pass=MD5('<new password>') WHERE user_login = '<user login>';
    
    e.g.
    UPDATE wp_users SET user_pass=MD5('mysecurepassword') WHERE user_login = 'admin';
  6. You will receive a confirmation message if the change was successful.
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
  7. Confirm if the password has changed based on the new hash generated.
    SELECT user_login, user_pass FROM <users table> WHERE user_login = '<user login>';
    
    e.g.
    SELECT user_login, user_pass FROM wp_users WHERE user_login = 'admin';
  8. You may now login using the new password set.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.