Changing a WordPress user password via SSH in a DigitalOcean droplet running a LAMP stack involves a few steps. You’ll be interacting with the MySQL database directly, so it’s important to be careful to avoid unintended changes. Here’s a step-by-step guide:
- Connect to Your Droplet via SSH:
Open your terminal or command prompt and use the SSH command to connect to your droplet. It typically looks like this:
username with your SSH user and
your_droplet_ip with your droplet’s IP address.
- Access MySQL:
Once connected, you need to access MySQL. The command usually looks like this:
mysql -u root -p
If you’re not using the
root user or if your database user is different, replace
root with your MySQL username. After entering this command, you’ll be prompted for the MySQL password.
- Identify the WordPress Database:
If you’re not sure what your WordPress database is called, you can list all databases with:
Look for something that seems like it would be your WordPress database (often it’s named
wp, or something similar).
- Use the WordPress Database:
Once you’ve identified the database, switch to it using:
database_name with the name of your WordPress database.
- Update the User Password:
WordPress uses the MD5 hash to store passwords. You’ll need to update the password using an MD5 hash. First, identify the user whose password you want to change:
SELECT ID, user_login FROM wp_users;
Then, update the password with:
UPDATE wp_users SET user_pass = MD5('new_password') WHERE user_login = 'your_username';
new_password with your new desired password and
your_username with the WordPress username.
- Exit MySQL and SSH:
After updating the password, exit MySQL by typing
exit, then disconnect from SSH by typing
A few important notes:
- Be sure to replace placeholders (like
database_name) with your actual details.
- The WordPress database tables might have a different prefix instead of
wp_, so adjust your commands accordingly.
- Always back up your database before making direct changes as a precaution.
Remember, working directly with the database can be risky, so make sure you are confident in what you are doing or seek assistance from someone who is.