Forgetting your WordPress admin password can be frustrating, but the good news is that there are multiple methods to reset it. This guide will walk you through each step in detail, with examples and code snippets where necessary, so you can quickly regain access to your WordPress site.
In this post, we’ll cover five main methods to reset your WordPress admin password:
- Using the WordPress built-in password reset option.
- Resetting the password via the WordPress database using phpMyAdmin.
- Editing your
functions.php
file to reset the password. - Using WP-CLI to reset the password.
- Using the emergency password reset script.
Method 1: Resetting WordPress Admin Password via Built-In Password Reset Option
This is the easiest and most common method for resetting your password, especially if you still have access to the email associated with your WordPress account.
Step-by-Step Instructions:
- Go to the Login Page: Visit your WordPress login page by typing
/wp-admin
or/wp-login.php
after your website’s URL (e.g.,yourwebsite.com/wp-admin
). - Click on “Lost your password?”: Under the login form, click on the “Lost your password?” link.
- Enter Your Email: Enter the email address associated with your WordPress admin account and click Get New Password.
- Check Your Email: You will receive an email with a password reset link. Open the email and click on the link.
- Create a New Password: After clicking the link, you’ll be redirected to a page where you can enter a new password. Once you’ve chosen a strong password, click Save.
That’s it! You should now be able to log in using your new password.
Method 2: Resetting WordPress Admin Password via phpMyAdmin
If you don’t have access to the email associated with your WordPress account, you can reset your admin password directly from your WordPress database using phpMyAdmin.
Step-by-Step Instructions:
- Login to Your Web Hosting Control Panel (cPanel): Access your hosting control panel (such as cPanel) and navigate to phpMyAdmin.
- Select Your WordPress Database: In phpMyAdmin, find the database for your WordPress site in the left-hand sidebar and click on it.
- Find the wp_users Table: Scroll through the list of tables and locate the one called
wp_users
(the prefix may differ if you changed it during installation). - Edit Your Admin User: In the
wp_users
table, find the row that corresponds to your admin account (usually the user withID 1
). Click the Edit link next to it. - Change the User Password:
- Look for the
user_pass
field. - In the “Function” dropdown next to it, select MD5 (WordPress used to hash passwords with MD5, but will rehash it securely when you log in).
- In the “Value” field, enter your new password.
UPDATE `wp_users` SET `user_pass` = MD5('new_password_here') WHERE `ID` = 1;
- Look for the
- Save Changes: Scroll down and click Go to save your changes.
Now, you should be able to log in to your WordPress admin dashboard using your new password.
Method 3: Resetting WordPress Admin Password via functions.php
If you’re locked out of your WordPress dashboard and don’t have access to the database, you can reset your password using the theme’s functions.php
file.
Step-by-Step Instructions:
- Access Your Site via FTP or File Manager: Use an FTP client or your hosting file manager to access your WordPress files.
- Navigate to Your Theme Folder: Go to
wp-content/themes/your-active-theme/
. - Edit the
functions.php
File: Download or edit thefunctions.php
file and add the following code at the bottom:function reset_admin_password() { $user_id = 1; // The admin user ID wp_set_password( 'newpassword', $user_id ); } add_action( 'init', 'reset_admin_password' );
- Upload and Save the File: Save your changes and upload the file back to the server.
- Log In and Remove the Code: Now, log in to your WordPress dashboard using the new password
newpassword
. After successfully logging in, go back and remove the code from yourfunctions.php
file to avoid security issues.
Method 4: Resetting WordPress Admin Password via WP-CLI
If you have access to your server’s command line interface and WP-CLI is installed, resetting the admin password is quick and efficient.
Step-by-Step Instructions:
- Connect to Your Server via SSH: Use an SSH client like PuTTY to connect to your server.
- Navigate to Your WordPress Directory: Once logged in, change the directory to your WordPress installation:
cd /path/to/your/wordpress
- Run the Command to Reset the Password: Use the following WP-CLI command to reset the admin password:
wp user update admin --user_pass="new_password_here"
Replaceadmin
with your actual admin username, andnew_password_here
with your desired password. - Log In: After running the command, log in to your WordPress dashboard with the new password.
Method 5: Using the Emergency Password Reset Script
If all else fails, WordPress provides an emergency password reset script you can use to reset your admin password.
Step-by-Step Instructions:
- Download the Emergency Password Script: Go to the official WordPress site and download the emergency password reset script.
- Upload the Script to Your Root Directory: Use FTP or your hosting file manager to upload the script to the root directory of your WordPress installation (the same directory as
wp-config.php
). - Run the Script: In your browser, navigate to the script:
http://yourwebsite.com/emergency.php
- Enter Your Admin Username: Enter the admin username and new password, then click Reset Password.
- Delete the Script: After successfully resetting the password, make sure to delete the script from your server to prevent security vulnerabilities.
Tips for Keeping Your WordPress Password Secure
- Use Strong Passwords: Always use a strong password that includes uppercase letters, lowercase letters, numbers, and symbols.
- Enable Two-Factor Authentication: Add an extra layer of security by enabling two-factor authentication (2FA) on your WordPress site.
- Regularly Update Passwords: Change your password regularly to reduce the risk of your account being compromised.
- Limit Login Attempts: Install a plugin like Limit Login Attempts Reloaded to prevent brute force attacks.
Resetting your WordPress admin password is relatively straightforward, even if you’re locked out of your email or dashboard. Whether you prefer to use the built-in reset option, access phpMyAdmin, or use advanced tools like WP-CLI, this guide has provided several methods for you to regain access to your WordPress site.
By following these methods, you’ll be able to restore access to your WordPress dashboard in no time, ensuring that you can continue managing your site without disruption.