Learn how to change a WordPress user password via SSH without phpMyAdmin or WP Admin using MySQL. Easy step-by-step guide.
How to Change a WordPress User Password via SSH
Losing access to your WordPress dashboard can be stressful, especially when you also can’t use phpMyAdmin or your hosting control panel. This situation often occurs when a hosting panel license expires, the server is experiencing issues, or the WordPress login credentials are forgotten.
Fortunately, if you have SSH access to your Linux server, you can still reset any WordPress user’s password within a few minutes. By connecting to your server through SSH and accessing the WordPress database directly, you can update the password without needing the WordPress admin dashboard or phpMyAdmin.
In this step-by-step guide, you’ll learn how to change a WordPress user password via SSH using MySQL. The process works on most Linux servers, including those running Plesk, cPanel, DirectAdmin, or any VPS or dedicated server where SSH access is available.
Why Reset a WordPress Password via SSH?
Using SSH is one of the fastest and most reliable methods to recover access to a WordPress website.
This method is especially useful when:
- You forgot your WordPress administrator password.
- phpMyAdmin is unavailable.
- Your Plesk or cPanel license has expired.
- The WordPress login page is inaccessible.
- You only have SSH access to the server.
- You need to recover access quickly without reinstalling WordPress.
Unlike using the “Lost Password” option, SSH allows you to reset passwords even if email services are not working.
Prerequisites
Before starting, make sure you have:
- SSH access to your server
- Root or sudo privileges
- A Linux VPS or Dedicated Server
- WordPress installed on the server
- A terminal application such as PuTTY, Windows Terminal, or Terminal (macOS/Linux)
Step 1: Connect to Your Server Using SSH
First, connect to your Linux server using SSH.
ssh root@your-server-ip
Replace your-server-ip with your server’s actual IP address.
After logging in successfully, you’ll have access to the Linux command line.
Step 2: Find Your WordPress Installation Directory
Before changing the password, you need to locate your WordPress installation.
Run the following command:
find /var/www -name wp-config.php 2>/dev/null
Example output:
/var/www/vhosts/example.com/httpdocs/wp-config.php
The directory containing the wp-config.php file is your WordPress root directory.
If your server hosts multiple websites, this command will display every WordPress installation available on the server.
Tip: If you’re using Plesk, your WordPress files are commonly located under:
/var/www/vhosts/domain-name/httpdocs/
Step 3: Retrieve the WordPress Database Credentials
WordPress stores all database connection details inside the wp-config.php file.
Display them using:
grep DB_ /var/www/vhosts/example.com/httpdocs/wp-config.php
Example output:
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');
From this information, note down:
- Database Name
- Database Username
- Database Password
- Database Host
These credentials are required to access the MySQL database.
Step 4: Log in to the MySQL Database
Once you have the database credentials, log in to MySQL.
mysql -u wordpress_user -p
Enter the database password when prompted.
If the credentials are correct, you’ll see the MySQL or MariaDB prompt.
Example:
MariaDB [(none)]>
At this stage, you’re connected to the database server but haven’t selected your WordPress database yet.
Step 5: Select the WordPress Database
Now choose your WordPress database.
USE wordpress_db;
If everything is correct, MySQL will display:
Database changed
This step is essential because running SQL commands before selecting a database results in the following error:
ERROR 1046 (3D000): No database selected
Selecting the correct database ensures all subsequent commands run against the appropriate WordPress installation.
Step 6: Find the WordPress Users Table
Every WordPress installation stores user accounts in a database table ending with _users. The default table name is wp_users, but many websites use a custom table prefix for additional security.
To find the correct users table, run the following SQL command:
SHOW TABLES LIKE '%users';
Example output:
+----------------+
| Tables_in_db |
+----------------+
| wp_users |
+----------------+
If your website uses a custom prefix, the output might look like this:
abc123_users
Important: Always use the table name returned by this command in the following steps.
Step 7: Display All WordPress Users
Before changing a password, it’s a good idea to view all available WordPress usernames.
Run:
SELECT ID, user_login FROM wp_users;
If your table has a custom prefix, replace wp_users with the appropriate table name.
Example output:
+----+-------------+
| ID | user_login |
+----+-------------+
| 1 | admin |
| 2 | editor |
| 3 | manager |
+----+-------------+
This command helps you identify the exact username whose password you want to reset.
Step 8: Change the WordPress User Password
Once you’ve identified the username, update its password using the following SQL query.
UPDATE wp_users
SET user_pass = MD5('YourNewStrongPassword123!')
WHERE user_login='admin';
Replace:
adminwith your WordPress username.YourNewStrongPassword123!with your preferred secure password.
If the query is successful, you’ll receive a message similar to:
Query OK, 1 row affected
At this point, the password has been updated successfully.
Step 9: Exit MySQL
After completing the password reset, simply exit the MySQL shell.
EXIT;
You can now log in to your WordPress dashboard using the new password.
Common Errors and Their Solutions
Error: No Database Selected
One of the most common errors is:
ERROR 1046 (3D000): No database selected
Cause
The WordPress database wasn’t selected before running SQL commands.
Solution
Run:
USE your_database_name;
Then execute your SQL queries again.
Error: Table ‘wp_users’ Doesn’t Exist
Cause
Your WordPress installation uses a custom database table prefix.
Solution
Run:
SHOW TABLES LIKE '%users';
Use the returned table name instead of wp_users.
Error: Access Denied for User
Cause
Incorrect database username or password.
Solution
Verify your database credentials by checking the wp-config.php file.
Error: Unknown Database
Cause
The database name entered is incorrect.
Solution
Review the DB_NAME value inside the wp-config.php file and try again.
Security Best Practices After Resetting the Password
After regaining access to WordPress, consider improving your site’s security by following these recommendations:
- Change the password again from the WordPress dashboard using a password manager.
- Enable Two-Factor Authentication (2FA) for administrator accounts.
- Remove unused administrator users.
- Keep WordPress core, themes, and plugins updated.
- Regularly back up your website and database.
- Limit SSH access to trusted IP addresses whenever possible.
- Disable unused user accounts and review administrator permissions regularly.
Why Use SSH Instead of phpMyAdmin?
Although phpMyAdmin is a popular database management tool, SSH provides several advantages.
SSH Advantages
- Works even when phpMyAdmin is unavailable.
- Ideal for VPS and dedicated servers.
- Faster for experienced administrators.
- Doesn’t require a web browser.
- More reliable during hosting control panel issues.
- Suitable for server recovery situations.
If your Plesk or cPanel license expires, SSH often remains available, making it one of the best recovery methods.
Frequently Asked Questions
Can I reset a WordPress password without phpMyAdmin?
Yes. As long as you have SSH access and the WordPress database credentials, you can reset any user’s password directly through MySQL.
Does this method work on Plesk servers?
Yes. This method works perfectly on Plesk servers, even if the Plesk license has expired, provided you still have SSH access.
Will changing the password affect my website?
No. Updating the password only changes the selected user’s login credentials. Your website content, plugins, themes, and settings remain unchanged.
Can I reset any WordPress user’s password?
Yes. Simply replace the username in the SQL query with the desired WordPress username.
Is SSH safer than using phpMyAdmin?
Both methods are secure when used correctly. However, SSH is often preferred by system administrators because it provides direct, encrypted access to the server and doesn’t depend on a web interface.
Conclusion
Knowing how to change a WordPress user password via SSH is an essential skill for WordPress administrators and server managers. Whether you’ve forgotten your login credentials, lost access to phpMyAdmin, or your hosting control panel is unavailable, SSH allows you to regain access quickly and safely.
The process is straightforward:
- Connect to your server via SSH.
- Locate the WordPress installation.
- Retrieve the database credentials from
wp-config.php. - Log in to MySQL.
- Select the correct database.
- Find the users table.
- Display the available WordPress users.
- Update the desired user’s password.
- Log in using the new credentials.
By following these steps, you can recover access to your WordPress website in just a few minutes without reinstalling WordPress or relying on additional tools.
Helpful External Resources
For additional information, these official resources are worth bookmarking:
- WordPress Password Management: https://developer.wordpress.org/advanced-administration/security/application-passwords/
- MySQL Reference Manual: https://dev.mysql.com/doc/
- OpenSSH Documentation: https://www.openssh.com/manual.html







