Reset WordPress admin password, no email/ PHPMyAdmin access

reset wordpress password


I have a small WordPress blog running live through Digital Ocean server. I don’t publish new posts quite often and it had been a while since I had logged in to my WordPress admin panel.

I tried logging in but I couldn’t. I simply forgot what password I had set, I tried every password but didn’t work.

My problem here was:

  • I tried lost password? link to reset password but I didn’t receive any reset emails (maybe because I had turned off mail() function or for other reasons)
  • since I was hosting with digital ocean’s WordPress default image, I didn’t have PHPMyAdmin and couldn’t change the password through PHPMyAdmin, (there could be another way around accessing database but it took me some time to find out how to do it and I eventually gave up)
  • I couldn’t reset the password, and following is what I found on the internet and it worked for me.

Reset WordPress password through file manager – functions.php

For this, you need to have access or get connected to your server. You might need to browse through FTPs, SSH or any other way.

I did an SSH login via the terminal to my digital ocean droplet and navigated to find where my WordPress functions.php file was located.

For me the location was:

root@myserver:/var/www/html/wp-content/themes/mytheme# 

Generally, you will find your functions.php file inside themes folder in wp-content.



You will need editor to add a line to functions.php.

To edit with vim,

vi functions.php

add this line under the line containing <?php


Your Gift of $200 Cloud Hosting Credit is Here. Claim Now!
wp_set_password('new-password', 1);

Save your file, in vim use keys: i to inset, ctrl+o, :wq to write and quit.

new-password: the password you would like to create 1: user id number, if you are unsure about id number, you can use wp user list command or if you have few users accounts you can try my way: I have 3 user accounts and I tried resetting the password to each account as:

wp_set_password('new-password', 1);
wp_set_password('new-password', 2);
wp_set_password('new-password', 3);

This actually worked for me.




Now go to your WordPress login URL, when you try logging in, you will find that you won’t be able to log in, as this would reset the password.

Now, return back to above functions.php file and remove the lines that you just added and try logging in, and you will get access into it.

Comment down, if you are confused anywhere. 🙂

Before you go, let's stay connected
About the Author
Lakshman Basnet
Nepali Digital Media Marketer currently based in Adelaide, South Australia who apart from playing with his cat - Eleven, also enjoys developing web content, publishing blogs and YouTube videos in his free time.

Leave a Comment