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:
Generally, you will find your
functions.php file inside
themes folder in
You will need editor to add a line to functions.php.
To edit with vim,
Your Gift of $200 Cloud Hosting Credit is Here. Claim Now!
add this line under the line containing
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.
Don't forget to subscribe!.
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. 🙂