Are you trying to access your WordPress admin page and discovered that you have lost your password? Usually, you can easily change your WordPress admin password with the reset link on your login page.
In some cases, however, your WordPress site may fail to send an email. And when this happens, you will need an alternate means to reset your password and access your admin panel.
Well, there’s no need to panic. In this article, we will show you what to do.
- How to reset your WordPress password via FTP
- How to reset your password using PHPMYADMIN
- Steps to reset your WP password using Emergency Password Reset Script
- How to reset your WordPress password using MYSQL Command Line Command Prompt
- And how to reset your password through WP-CLI.
Any of these steps should work great for you. Simply pick the one you are most comfortable with and proceed. Now let’s jump into the solutions, starting from one of the easiest methods.
How To Reset Your WordPress Admin Password via FTP
To start, launch FileZilla and login to your FTP account by inputting your host, username, password, and port number in the text fields provided.
To help you out, the host is ‘yourdomainname.com’, the username and password are most often your control panel login details. And the port is usually 21. However, if you do not have any of these details, simply contact your WebHost and request for them.
After you have put in the correct details, click on the ‘Quickconnect’ button.
Now we want to get to the directory of the WordPress theme that is currently active on your website or blog.
To get there, go to the window on the right that is tagged ‘Remote Site’, scroll down to find the folder containing your website (usually ‘public_html’), and double-click on it.
Next, on the ‘Filename’ window that is also on the right, then scroll down to ‘wp-contents’ and double-click on it. Once it is open, double-click on the ‘Themes’ folder to open it.
You will see the folders of different themes. So double-click on your active theme.
Once the folder is open, scroll down to ‘functions.php’. Now, if you just installed FileZilla, you will also need to set up the text editor you want to use to edit the php file. The easiest option is to set FileZilla to use the default editor in your system (unless you have a preference for another editor).
So to do this, move your cursor to the top left of your screen and click on Edit. On the drop-down menu, select Settings.
Head down to File editing and click on it. In the ‘Default editor’ section, select ‘Use system’s default editor…’ and click OK.
Now back to our ‘functions.php’ file, right-click on this file and select View/Edit from the options.
This will take you to the text editor. Here you will make a little change to the code.
At the top, after the <?php line, copy and paste this code:
wp_set_password( ‘your_new_password’, 1 );
Replace ‘your_new_password’ with the actual password you want to use, and ‘1’ is the user ID of the WordPress user for whom you want to reset the password. This user id corresponds to the very first admin user created while installing WordPress.
Once you’re done, save your changes and close the file. FileZilla will then ask if you want to upload the file, so select Yes.
Now login to your WordPress dashboard using the password you just set.
You have successfully reset your password. Therefore, you have to go back to your FTP client and remove the ‘wp_set_password’ code from your ‘functions.php’ file.
Use the same steps above to access and edit the file to remove the code we added. And of course, save and upload the file when done.
Doing this will prevent WordPress from resetting the password every single time you try to access the admin dashboard.
How To Reset Your WordPress Admin Password Using PhpMyAdmin
This is another way you can reset your password directly from the database.
PhpMyAdmin is the software for managing your database. Using it, you can make direct changes to your WordPress database.
To use this software, you will have to log in to your WordPress hosting account’s control panel (often cPanel).
To access cPanel, enter your domain name on your browser and add “:2083” to it. This should work for most web hosts, but if it doesn’t for you, please contact your WebHost.
Next login to cPanel with your credentials.
Under the ‘Databases’ section, click on phpMyAdmin; you will be redirected to the phpMyAdmin page.
On the page, it shows you a list of all your databases. So, click on the database related to your WordPress site which is on the left-hand side of the page. It is usually your ‘username_wpXX’.
This will bring out a list of tables on your database. On the ‘Structure’ tab, look for the ‘wp_users’ table on the list and click on ‘Browse’ next to it.
This will show you all the users on your WordPress site. Select the ‘Edit’ link next to your user account. A page with all your user information will also be shown.
In the field next to ‘user_pass’ you will see a long string of numbers and letters. Delete it and put in your new password. Under the ‘Function’ column, click on the drop-down menu and select ‘MD5’ and then click the ‘Go’ button.
You have succeeded in changing your WordPress password. Go ahead and login.
How To Reset Your WordPress Admin Password via Emergency Password Reset Script
You can fall back to the Emergency Password Reset Script if the solutions above are not appropriate for you. Note that it is not a plugin but rather a PHP script. To use this, it is important that you know the following:
- You know your administrator username.
- The script updates the admin password and usually sends a confirmation email to the admin user.
- Even if the email is not sent, rest assured that the password has changed.
- You must place the script in the root folder of your WordPress installation.
- For security reasons, delete the script once you are done.
Now that we know all these, let us explain how to create it.
You can create this script using either FTP or the control panel on your host. We will show you how to do this with cPanel.
To start, login to your cPanel and select ‘File Manager’ under the ‘Files’ section.
In the ‘File Manager’ page, click on the folder containing your WordPress files to open it. In most cases, this will be ‘public_html’.
Within the public_html folder, create a new file by clicking the ‘+File’ item at the left-hand pane of your screen. A box will pop up. Then in the ‘New File Name:’ field, type in ‘emergency.php’ and select ‘Create New File’ to create the file.
Once the file has been created, right-click on it and select ‘Edit’.
You may get another box asking you to back up the original file, but seeing as it is an empty file, just go ahead and click the ‘Edit’ button below it.
Next, copy the Emergency Password Script and paste it into the emergency file. Now click ‘Save Changes’ on the right-hand pane of the page.
After creating the file, go to http://yourdomain.com/emergency.php on your browser (of course replace yourdomain with your actual site url). Now enter your Admin username and your new password in the text fields and click ‘Update Options’.
A message will be shown notifying you of the password change. An email will then be sent to the Administrator’s email address with the password change information. Remember, even if you do not get an email, the password has been changed.
To wrap up, you have to delete the ‘emergency.php’ file from your server to prevent someone else from using it to change your password.
Reset WordPress Admin Password via MYSQL Command Line Interface
Resetting your WordPress password can also be achieved through a MySQL CLI (Command Line Interface) on your host server.
However, you need to have shell access on your WordPress hosting server to follow along with this guide.
To reset your password using MySQL, you need to access your website via SSH.
How to Access your Website Via SSH
If you are on a Linux or OSX Operating system, you can simply use the SSH command on your terminal.
First, Open terminal, then type in or paste the code below.
ssh USER@SERVER -pPORT
Ensure you replace USER with your cPanel login username or VPS user. Then replace SERVER with your host IP address. Finally, replace the PORT with the ssh port number of your host server.
Meanwhile, if you are on Windows OS, you will need an SSH client to connect your website. We will use PuTTY (a CLI for Windows users) to establish an SSH connection in this example.
Firstly, download and install PuTTY. After installation, launch the application.
In the PuTTY window, input your IP address (or your domain name), and your SSH port number in the text input boxes as shown below.
Secondly, set the connection type to SSH and click on Open to launch the terminal window.
In this terminal, enter your WebHost username and password details.
Side Note: If you do not have your SSH details, then you should be able to get them from your control panel. In cPanel, click the Manage Shell menu link and you should see these details. Otherwise, you may request them from your WebHost.
Using MySQL CLI to Reset Password in WordPress
After successfully connecting your website, type in the command below to open the MySQL interface.
mysql -u root -p
Ensure you replace ‘root’ with your database username (if it is different).
Next, click on enter. You will be prompted to enter your database password.
You can find your database username and password on the wp-config file on your host server.
To do this, login to the cPanel of your WordPress site, then Click on File Manager.
After that, open the folder containing your WordPress site (often public_html).
Next, click on wp-config and select edit.
You should see all the details about your database after opening the file.
After connecting your site on the MySQL CLI with these details, the next step is to access your database. Type the command below on the shell.
Replace ‘your_database_name’ with your websites’ database. Similarly, you can find the name of your database in the wp-config.php file as shown above.
Now type the command below, to get all tables with users’ details.
show tables LIKE '%users';
You should see the wp_users table outputted on the terminal.
Next, we will write an sql command to query the database and get the admin user. For this, paste the code below on the terminal.
SELECT ID, user_login, user_pass FROM wp_users WHERE user_login = 'your_username';
Replace ‘your_username’ with your WordPress dashboard username.
You should see a table containing the unique ID of the user, the username, and the password of the user.
Now, to reset your password, type the following command on the terminal.
UPDATE wp_users SET user_pass=MD5('new_password') WHERE user_login = 'your_username';
Replace new_password with your new password. Also, replace your_username with your WP admin username.
The UPDATE command above is used to reset user passwords in MySQL.
The ‘MD5’ parameter is used to automatically encrypt the password before storing it in the database.
To confirm that the password has been changed, type the command below.
SELECT ID, user_login, user_pass FROM wp_users WHERE user_login = 'your_username';
Under the user_pass column, the password stored should be different from the one seen during the initial query.
To exit the MySQL CLI, simply type exit then hit the enter key.
Reset Password Through WP-CLI
Another method of resetting your WordPress sites’ password is through the WP-CLI. But to use the WP-CLI, you need to connect your site via SSH access.
Above, we have shown you how to access SSH via the terminal (for Linux and OSX users), and also using Putty(for Windows users).
After connecting your site to an SSH terminal, you will also need to navigate to your WordPress site’s directory. For this, you can use the ‘cd’ command followed by the name of the folder.
If your WordPress site is in another directory, then replace ‘public_html’ with the name of your sites’ folder.
Side note: To also see all the folders in the current terminal window, type the ‘ls’ command.
After navigating to your site directory, you will need to install WP-CLI on the terminal window. Paste the code below and hit enter to install on the Shell.
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
To confirm that WP-CLi has been installed on your site, paste the code below and hit enter.
php wp-cli.phar cli version
Now to change the password on your wordpress site, type the command below on the SSH terminal.
php wp-cli.phar user update USERNAME --user_pass="PASSWORD"
Replace USERNAME with your sites’ admin user. Replace PASSWORD with your desired new password.
Congratulations, you have successfully changed your WordPress sites’ password.
After logging in to your WordPress dashboard using one of the means listed above, you should check to see why you could not reset your admin password using the link on the login page.
This is usually a problem with your emails not getting sent from your WordPress account. If this is your issue, then you should read our guide on how to fix WordPress not sending email issues on your site.
We would also suggest that you store your password in a secure place only you will have access to. This way, even if you forget it, you can always refer to it.
- How to fix ‘sorry you are not allowed to access this page’ error
- Cannot login to WP Admin Dashboard? How to fix it
- How to limit login attempts in WordPress