Forgetting your WordPress admin password can be frustrating, but thankfully, you can easily reset it using the command line. This is especially useful if you don't have access to the WordPress dashboard. In this guide, we'll walk you through how to reset your WordPress admin password directly from the command line. Using a WindowsVPS can simplify WordPress management, giving you the performance and control that only a VPS server can offer.
Step 1: Access Your VPS Server
If you're hosting your WordPress site on a VPS, the first step is to connect to your server via SSH. If you're using a WindowsVPS, you can connect to your server using an SSH client like PuTTY or the terminal if you're on Linux or macOS. Run the following command to access your server:
ssh username@your-server-ip
Make sure to replace username
with your actual VPS username and your-server-ip
with the IP address of your VPS.
Step 2: Navigate to Your WordPress Directory
Once connected to your VPS server, navigate to the directory where your WordPress installation is located. The default location is typically inside the /var/www/html
directory:
cd /var/www/html
If your WordPress installation is in a different location, adjust the path accordingly.
Step 3: Access the MySQL Database
Your WordPress admin password is stored in the database. To reset it, you'll need to access MySQL. If you're using a WindowsVPS to host your site, MySQL should already be installed and configured. Log into the MySQL database with the following command:
sudo mysql -u root -p
Enter the MySQL root password when prompted. If you're unsure of your MySQL password, it can be found in your VPS server configuration files.
Step 4: Select the WordPress Database
Once you're logged into MySQL, you need to select the database where WordPress is installed. First, list all databases with this command:
SHOW DATABASES;
Identify your WordPress database from the list, then select it with the following command:
USE your_database_name;
Replace your_database_name
with the actual name of your WordPress database.
Step 5: Update the Admin Password
Now that you’re inside the WordPress database, you can reset the admin password. To do this, run the following SQL command, replacing newpassword
with the desired new password and admin
with your admin username:
UPDATE wp_users SET user_pass = MD5('newpassword') WHERE user_login = 'admin';
The MD5()
function encrypts the password, which is how WordPress stores passwords in the database. Make sure the table prefix wp_
matches your actual WordPress table prefix.
Step 6: Verify the Password Update
To ensure the password was updated correctly, you can query the database to check if the new password has been applied:
SELECT user_login, user_pass FROM wp_users WHERE user_login = 'admin';
This will display the username and encrypted password for the admin account. Once verified, you can exit MySQL:
EXIT;
Step 7: Log in to WordPress
With the password updated, you can now log in to your WordPress admin dashboard using your new credentials. Navigate to http://your-domain.com/wp-admin
and enter your admin username and the new password you set.
If you're hosting your WordPress site on a WindowsVPS, the VPS server will offer you the stability, speed, and control needed to manage your WordPress site effectively.
Conclusion
Resetting your WordPress admin password via the command line is a quick and effective way to regain access to your site, especially when you don't have access to the dashboard. By hosting your WordPress site on a WindowsVPS, you benefit from a more secure, high-performance hosting environment, ensuring your WordPress site runs smoothly even as it grows.
For more information on VPS hosting and WordPress management, visit WindowsVPS to explore their VPS server options.