Let me guess…you’ve lost your WordPress admin password, you have no other admins to recover it, and you don’t have access to the admin email account either? Well I hope that you haven’t gotten yourself stuck in that sorry situation, but in case you have go ahead and do this:
Open your site through FTP or cPanel File Manager and add this line just inside the closing ?>
of your site’s wp-login.php
file (found in the root of your installation):
wp_set_password('foobar',1);
Now, open up a browser go to your WordPress site’s login page (/wp-login.php
or /wp-admin
) and login using your new password (foobar
in this case).
At this point you need to remove the wp_set_password
line from wp-login.php
and then you’re done. You can now change your password from within the WordPress admin.
The first parameter is the new password you would like to set, and the second parameter is the WordPress user ID. If you need to lookup your user ID connect to your WordPress database using phpMyAdmin or another SQL client and look in the wp_users
table.
I’m not sure why the Internet is full of pages suggesting running SQL commands, that hasn’t worked for a while since the passwords are not stored using the MD5 algorithm anymore. Even the WordPress Codex has outdated methods, although it does include the method I have shown you.
Happy log-ins WordPress travelers!