What to Do If You Need to Reset WordPress Admin Password via FTP

reset admin password

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.

We are FixRunner team, a group of dedicated WordPress experts committed to providing top-notch WordPress support and solutions. Our team, with years of experience in handling a wide array of WordPress challenges, offers personalized support, ensuring your website operates smoothly and efficiently.

Content

  1. How to reset your WordPress password via FTP
  2. How to reset your password using PHPMYADMIN
  3. Steps to reset your WP password using Emergency Password Reset Script
  4. How to reset your WordPress password using MYSQL Command Line Command Prompt
  5. 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

You can reset WordPress password by using an FTP client. In this example, we’ll be using FileZilla. See this guide to learn how to use 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.

Enter FTP login details - Reset your WordPress admin password

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.

Open public_html - Reset your WordPress Admin Password

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.

Themes folder - Reset your WordPress admin password

You will see the folders of different themes. So double-click on your active theme.

Open the active theme - Reset your WordPress admin password

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.

Edit settings - Reset WordPress admin password

Head down to File editing and click on it. In the ‘Default editor’ section, select ‘Use system’s default editor…’ and click OK.

Click 'File Editing' - Reset WordPress admin password

Now back to our ‘functions.php’ file, right-click on this file and select  View/Edit from the options.

function.php file

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 );

wp_set_password

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.

ResetYour WordPress Admin Password via FTP

Doing this will prevent WordPress from resetting the password every single time you try to access the admin dashboard.

How To Reset 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.

Logging in to cPanel

Under the ‘Databases’ section, click on phpMyAdmin; you will be redirected to the phpMyAdmin page.

Databases >> PHPadmin

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’.

Enter username

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.

Click 'Browse'

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.

Reset password with PHPMyAdmin

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.

Reset password via PHPMyAdmin

You have succeeded in changing your WordPress password. Go ahead and login.

How To Reset 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.

cPanel - Reset your WordPress Admin password

In the ‘File Manager’ page, click on the folder containing your WordPress files to open it. In most cases, this will be ‘public_html’.

Open File Manager - How to Reset your WordPress Admin Password via FTP

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.

Creating a new file - Reset your WordPress Admin Password

Once the file has been created, right-click on it and select ‘Edit’.

Editing Emergency.php

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.

Editing emergency.php file

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.

Save changes

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.

PuTTY window

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.

use 'your_database_name';

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.

Replacing ‘your_database_name’ with your websites’ database

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.

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.

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.

 

cd public_html

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.

Replace PASSWORD with your desired new password

Congratulations, you have successfully changed your WordPress sites’ password.

Frequently Asked Questions

Can I reset my WordPress password without email access?

Yes, you can reset your WordPress password without email access. This can be done through methods such as using phpMyAdmin to modify the database directly or using FTP to edit the functions.php file of your theme. Our article provides detailed steps for these methods.

Is it safe to reset my password using FTP?

Resetting your password via FTP is safe as long as you follow the correct procedures and ensure that you remove any temporary code used for resetting the password after the process is complete. Our guide outlines how to do this securely.

What should I do if I’m locked out of my WordPress admin account?

If you’re locked out of your WordPress admin account, you can use several methods to regain access, such as resetting your password via phpMyAdmin, using FTP, or employing the WordPress Command Line (WP-CLI) if you’re comfortable with command-line tools.

How to change WordPress password of another user as an admin?

As an admin, you can change another user’s password by accessing the WordPress dashboard, navigating to Users > All Users, selecting the user, and setting a new password in the Account Management section.

What is the best method to reset my WordPress password for non-technical users?

For non-technical users, the simplest method is using the ‘Lost your password?’ link on the WordPress login page, which allows you to reset your password via email. If email access is an issue, contacting your hosting provider for assistance or using a user-friendly tool like cPanel might be the next best option.

How often should I change my WordPress password?

It’s recommended to change your WordPress password regularly, at least every three to six months, to enhance security. Additionally, always change your password if you suspect any unauthorized access to your account.

Can I use WP-CLI to reset my password?

Yes, if you have SSH access to your server, you can use WP-CLI to reset your WordPress password. This method is more technical and is recommended for users who are comfortable with command-line interfaces.

What are the best practices for creating a strong WordPress password?

A strong WordPress password should be at least 12 characters long and include a mix of upper and lower case letters, numbers, and special characters. Avoid using easily guessable information like your name or common words.

Reference:

Conclusion

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.

Recommended Articles


Background vector created by GraphiqaStock – www.freepik.com