Working with WordPress, there are some essential commands you need to master to ensure you can easily handle your day-to-day activities. After all, even if you are a complete beginner, you have to be acquainted with the basics.
Today’s guide will teach you more about the importance of your WordPress passwords and how to quickly reset them through various methods.
When Do You Need to Reset Your WordPress Password?
There are numerous reasons why you might want to change or reset your WP passkey in the process of working with the app. For example, you can be an outside author who was given auto-generated credentials, and you might want to switch them to something more memorable. As WordPress is a CMS that lures in a lot of hackers, it’s not uncommon to have to switch your password to avoid an emerging vulnerability or suspected breach.
But the biggest reason in favor of frequently changing your WordPress login credentials is even more simple and obvious – better overall security. Even if your passwords are complex enough, it’s a good idea to switch them around from time to time. This way, you can prevent them from falling into some black market list of stolen credentials and causing tons of headaches in the long run.
With that in mind, here are some of the most common ways to reset a WP password.
How to Reset Your WordPress Password via the Automatic Emailer
This one is as easy as they come. Pretty much any online user has forgotten a password at least once, and the process of retrieving it is quite similar on many websites.
- Go to your WordPress admin page (default is yourdomain.com/wp-admin)
- Click on the blue link Forgot Your Password.
- Now, input either your WP username or WP email address to verify your identity.
- You can go ahead and log into your email account.
- Follow the link and type in your new password. Then retype to confirm.
How to Reset Your WordPress Password via the MySQL Command Line
You can also access WP’s database through the command-line interface and reset your password from there. Bear in mind, however, that this requires root MySQL access, which isn’t available on all plans.
- Create a new text file that contains the new password. You can do that by typing:
# vi newpassword.txt
- We now need to create an MD5 hash string for the new password. To do so, use the command:
# tr -d ‘\r\n’ < wp.txt | md5sum | tr -d ‘-‘
Save the newly-generated string to your local computer. Additionally, you can delete the text file for extra security. The command is:
# rm -rf newpassword.txt
- Now, login to your MySQL as root:
# mysql -u root -p
- Find the correct MySQL database:
> show databases;
> use wordpress;
- The next step is to open it to view its content:
> SELECT ID, user_login, user_pass FROM wp_users;
- You should now be able to see the MD5 string of the current password. We need to replace it with the one we generated earlier. You can do so with the following command:
> UPDATE wp_users SET user_pass=(‘newMD5string’) WHERE user_login = ‘admin’;
- If you want to test if the new password has been successfully updated by typing:
> SELECT ID, user_login, user_pass FROM wp_users;
How to Reset Your WordPress Password via phpMyAdmin
- Log in to your control panel.
- Find the phpMyAdmin option under the Databases section.
- Find your WordPress database and select the wp_users table on the left. Click Edit.
- Input your new password in the user_pass field and select MD5 from the drop-down.
- When you click Go, the system should return a message that you have successfully updated your database record.
How to Reset Your WordPress Password via FTP
- Log in to the FTP client of your choice.
- Navigate to the functions.php file and download it locally.
- You can now execute the following command:
wp_set_password(‘newpassword’,’admin’);
- Next, we need to upload the functions.php file back to our /themes folder (or the specific folder you downloaded it from).
- Go ahead and log into your WordPress dashboard. Once in, make sure to remove the wp_set_password line you added in step 3, or it will keep resetting after every page load.
How to Reset Your WordPress Password via WP CLI
WP CLI basically works like a WordPress terminal that allows you to execute commands. As such, it is predominantly preferred by developers and experienced users. To use WP CLI for your password reset, simply:
- Log in and open the /wordpress directory.
- Once inside, type:
$ wp user list
This will show you a list of all registered users for your WordPress installation.
- Find the ID of the user you are trying to modify and run the following command:
$ wp user update userID –user_pass=newpassword
You simply need to replace userID with the correct user and newpassword with the passkey of your choice.
How to Reset Your WordPress Password Using the Emergency Password Reset Script
If all else fails, you can always try utilizing a PHP script that serves this exact purpose – the Emergency Password Reset Script. To do that, you would need to know the admin username and have access to the administrative email address.
- Place the script in your root WordPress folder (not the Plugins directory).
- Copy the entire Emergency Password Reset Script from the official WordPress repository.
- Create a new file in your root WP folder and name it emergency.php. Paste the script inside.
- Open the script in your browser by typing:
http://yourdomain.com/emergency.php
- Enter the admin username (the default is admin unless you’ve changed it) along with the new password you’ve chosen. Hit Update Options afterward.
- Test if everything works and delete the emergency.php file afterward.
IMPORTANT: The last step is crucial as keeping the Emergency Password Reset Script on your server will leave it vulnerable for any savvy hacker to exploit and lock you out of your WordPress account.
We hope this guide has helped you with resetting your WP password and learning more about the most popular CMS. If you have more questions – you can always contact the ScalaHosting Support for assistance.