I’ll make this post short and sweet. Let’s say you’ve forgotten your login for a WordPress site. To reset the password to something new, you can simply use a SQL query. If you have access to PHPMyadmin or the MySQL command line, this is really straight forward.
From PHPMyAdmin, open the database for the WordPress installation. If you don’t know which database to use, check out your wp-config.php file inside your main WordPress installation folder. You’ll find constants defined in that file for your database name and database user. Once you’ve found the database, you can execute a SQL statement by clicking the SQL button. In there, type:
UPDATE wp_user SET user_pass = MD5("yourpassword") WHERE user_login = "admin"; |
That’s assuming that your username is “admin”. Change it to whatever username you are using. Once you run that SQL statement, your password will be set to whatever you put in “yourpassword”. Both the username and password need to be quoted in the SQL statement.
To do the same thing in the MySQL command line, connect to the database with:
mysql -u<username> -p |
Substitute <username> with your actual username from the wp-config.php file.
You will be prompted for a password. Use the password from the wp-config.php file.
Once you are logged into the mysql command problem type:
USE <databaseName> |
Substitute the actual database name from the wp-config.php file.
Finally, type the update statement above and hit enter.
After you’ve updated the table via SQL, you should be able to login to your WordPress installation.