2 Ways to Reset & Restore Passwords on WordPress

Looking to reset your WordPress password? If you can’t reset the password for any reason, there’s a simple way to do it directly through the database using phpMyAdmin.

In this guide, we’ll show you how to reset, or in other words, how to change the WordPress password via phpMyAdmin.

Additionally, we’ll explore an alternative method that allows you to log in to the WordPress admin interface without accessing phpMyAdmin. This can be done by adding a new user through the functions.php file.

For the purpose of password reset using phpMyAdmin, you’ll need access to the server’s control panel where your site is hosted (cPanel in this guide). To create a new user via the functions.php file, you’ll need FTP access to your server.

2 Ways to Reset a WordPress Password

WordPress provides a very simple way to reset a password. Just go to the login screen and click on “Forgot Password”.

Reset / Restore WordPress User Password

Clicking will take you to the password reset page where you can enter your email or username to reset your password. Once you’re done, WordPress will send an email to the email address associated with your user account.

But what if you don’t have access to that email, or if WordPress fails to send the email? In such a situation, you won’t have the option to reset the password. In such cases, you’ll need to reset the password directly in the database, and the easiest way to do this is through phpMyAdmin.

First Method – How to Reset a WordPress Password via phpMyAdmin

The first thing you need to do is log in to the cPanel control panel provided by your hosting company. Then click on phpMyAdmin under Databases.

Clicking this button will open the phpMyAdmin screen where you need to select the WordPress database as shown in the following example:

Reset a WordPress Password via phpMyAdmin

At this stage, you’ll see a list of tables in the WordPress database. You need to find the {table-prefix}_users table and click on Browse.

Please note that the table prefix in your database might be different from the table prefix shown in this example.

Now you’ll see a list of rows in the WordPress users’ table. Go to the username for which you want to change the password and click on the edit button located next to it.

Edit WordPress users' table

phpMyAdmin will now show you a form with all the user information fields. You need to delete the value under the user_pass field and replace it with your new password. Under the function column, select MD5 from the dropdown menu and click the Go button.

The password will now be encrypted using the MD5 hash and stored in the WordPress database.

Note that in older versions, WordPress used the same MD5 to encrypt passwords. However, starting from version 2.5, WordPress began using stronger encryption technologies. Nevertheless, WordPress still recognizes MD5 to accommodate older versions.

When you log in with a password saved as an MD5 hash, WordPress will detect this and change the password using the new encryption algorithms.

Second Method – Adding a New User to WordPress via functions.php

Let’s assume you don’t have access to cPanel or phpMyAdmin. What can you do in this situation to reset a password? If you have FTP access to the server, you can add a new user with administrator privileges using the functions.php file.

Log in to the server using FTP and navigate to your theme’s functions.php file. Add the following code to it:

function sv_wp_admin_account(){
	$user = 'Username';
	$pass = 'Password';
	$email = 'email@domain.co.il';
	if ( !username_exists( $user )  && !email_exists( $email ) ) {
		$user_id = wp_create_user( $user, $pass, $email );
		$user = new WP_User( $user_id );
		$user->set_role( 'administrator' );
	} }

Change the details in lines 2-4 for the new user, making sure to choose a username and email that don’t already exist in the system so that this method works for you.

After adding this code, when you go to the WordPress login screen, a new user with administrator privileges will be created using the username and password you selected in the code.

I hope this guide helps you understand how to reset a WordPress password and helped you get out of a jam 🙂

Roee Yossef
Roee Yossef

I develop websites & custom WordPress themes by design. I love typography, colors & everything between, and aim to provide high performance, seo optimized websites with a clean & semantic code.


Leave a Comment