Home Blog WordPress Management How to reset the WordPress password through FTP

Resetting Password through FTP

How to reset the WordPress password through FTP

If you lost your WordPress administrator password, or you cannot login to the WordPress dashboard and you do not have access to the WordPress MySQL database, or the password reset functionality is not working, it is still possible to change your password through FTP. In this ten step easy to follow guide we will explain how to change the WordPress administrator password using FTP to be able to access the WordPress dashboard again. If you have access to the phpMyAdmin interface, you can read our WordPress tutorial How to reset a WordPress password using phpMyAdmin in 3 easy steps.

Procedure to reset password WordPress password using FTP

  1. Using an FTP client connect to your WordPress website.
  2. Navigate to the directory of the WordPress theme which is currently enabled on your blog or website. WordPress themes can be found in wp-configthemes directory.
  3. Download the file functions.php of your WordPress theme.
  4. Add the below line of code after the first <?php line. The number 1 at the end of the line of code is the user ID of the WordPress user you would like to reset the password for. If you are using the default administrator account you created when installing WordPress, the user ID is always 1.
wp_set_password('password',1);
  1. Save the changes and upload back the files function.php.
  2. Once uploaded, navigate to your WordPress dashboard login page, typically http://www.yourwebsite.com/wp-admin.
  3. Login to WordPress using the default administrator account name (typically admin) using the password password.
  4. Once you submit the credentials (try to login) the login page will simply reload without redirecting you to the WordPress dashboard. This means you  have just reset the WordPress administrator password to password. Do not try to login again for now. Each time you try to login, you will reset the WordPress administrator account password.
  5. Before trying to login again, using the FTP client download the modified functions.php file from the themes directory.
  6. Remove the line you have added before, save the changes and upload back the file.

Now you can login  to the WordPress dashboard with your administrator account using the password password.

WP White Security Tip: Once you manage to login, change the WordPress administrator password to a more secure password. A secure password should consist of at least 8 characters and should not be a dictionary word.

Also, if you want to learn more about WordPress security, read our definitive guide on WordPress security & hardening.


27 thoughts on “How to reset the WordPress password through FTP

  1. I can’t seem to get it to work. The username I have has Admin privileges but the password ‘password’ won’t login.

    What if I am not using the default Admin how do I figure out what the User ID number should be?

    Thanks

    1. Hi Serena,

      So did you sort out your problem then? Your answer is correct. Users ID are sequential in WordPress so if your user was the second one created, than the user ID is 2.

      Let me know if you need further assistance. You can always get in touch with us via our Contact Form.

    1. Hi Kaleem,

      The line “wp_set_password(‘password’,1);” that needs to be added in functions.php should be added below the first line “help@wpwhitesecurity.com.

  2. Didn’t work. Nothing happens. Maybe I’m using an old version of WordPress and this code doesn’t work? Any thoughts on how to change the default email so it sends the reset password to a live account?

    1. Hi Jerry,

      It should work on almost all versions (as long as you don’t have version 1 🙂 ). When it works it does not report a success or a failure, you just update the file, insert the password, change the file and login. If you have problems, maybe we can try something else. Do you have access to the WordPress database? If yes you can reset the password from there. Drop me an email on robert@melapress.com so we guide you through the rest.

      1. Hi Robert,

        OK. It did actually work. I just neglected to remove the code from the functions.php file after I was done. It actually resets the password… I get it!

        Need to update my theme and portfolio to feature my video production and motion graphics work. Any suggestions on a particular theme?

        Thank you!
        Jerry

  3. What if the username is not Admin, this does not seem to be working for me? I try and when I go to login Im getting the invalid username error. I have also tried user id 1, 2, 3, 4…any other ideas or any way to reset the username for id1?

    1. Hi Matt,

      If the default Admin account was renamed then you mus specify the new account name. In your case it seems you renamed the username and cannot find the right one. Do you have access to the database? Contact us on support@melapress.com and we will help you solve your issue.

    1. Hi WP,

      Thanks for sharing your script, very simple but definitely very handy! wp_set_passwords have been supported for very long, though not sure since when. But it is supported in all latest versions 🙂

  4. I get a Fatal error no matter what I try…

    Fatal error: Call to undefined function wp_set_password() in /../wp-includes/functions.php on line 2

    The Functions.php file looks like this

    <?php
    wp_set_password(password,1);

    /**
    * Main WordPress API
    *
    * @package WordPress
    */

    1. <?php
      Sorry it is

      wp_set_password('password',1);

      /**
      * Main WordPress API
      *
      * @package WordPress
      */

      I tried with single, double and no quotes…

  5. Just to update this.

    This is how I do it.
    1. Copy to functions.php, remember to change “Hello World”. Change user ID accordingly.

    2. Go to default URL.

    3. Go back to function and delete what you’ve pasted.

    4. Go to wp-admin, use the new password.

    1. Thanks for the feedback Edwin. Yes, that is another way of doing it. In both cases you are using SFTP so it is really up to the user which method he / she prefers.


Comments are closed.

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon
Please enable JavaScript in your browser to complete this form.

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon