OS: Ubuntu 20.04.2 LTS
DB: MariaDB 10.3.34
In this tutorial I am going to show you how to change the WordPress User Password through SSH and mysql statement in 6 simple steps. Always backup you configuration before making changes so that in the events something goes wrong you can revert back to the previous configuration.
There are times especially in a lab environment that you might have forgotten your username and password of your WordPress admin. So it is useful to be able to retrieve your username and reset the password from the database manually.
- Once you SSH into your web server running WordPress. If you have setup a username and password. Run the MariaDB application with the command below and enter the password:
If you have not set a admin username and password then the default is root with no password and you can just issue mysql to launch the MariaDB application.
mysql -u USERNAME -p
- There is a very high chance that you might have also forgotten the database you use to store WordPress data. You can use the following command to list the database in MariaDB. Hopefully you have given a name that you can associate with easily. If not you might have to manually look at the database to see which is the one for WordPress.
- Next Connect to the database once you identified the database name. You should see the Database Change and the prompt showing the database name.
- Now you can list the table to check if you have the wp_users table. If you have not done any changes to the default configuration your users should be stored in the wp_users table.
- Locate the user that you want to change the password by issue the following command to list the user in your WordPress database take not of the ID of the user.
SELECT * FROM TABLE;
- Now we can reset the user password using the following command.
UPDATE wp_users SET user_name = MD5(‘password”) WHERE ID = id_number;
You should see that Rows matched: 1 and Changed: 1 without warning. Once that is done you can then go to your WordPress site and login to your WordPress website.