This brief tutorial shows students and new users how to change a WordPress login password via the database on Ubuntu.
This lesson is about resetting or changing WordPress’ user password from the database server. Students who are new to WordPress sometimes forget their passwords and learning how to reset passwords from the database may come in handy someday.
WordPress is great at resetting forgotten passwords. There’s a password reminder link on WordPress logon page that sends a reset link to the registered admin email address on file. So, locking yourself out of WordPress can be pretty difficult.
However, I’ve been there before where I was locked out and couldn’t reset my password from the portal.
The admin account had a registered email address that I didn’t have access to, at least when I needed it right away.
So, each time I used the link to reset my password, WordPress sends the help link to the email address that I could’t access. There was no other way to reset my password.
I had to logon to the database server to reset the password which gives me access to the portal.
So, day you find yourself in similar situation, use this guide to unlock/reset your password.
Backing up WordPress Database
Before making changes to your WordPress database server, the first thing you should always do is take a backup copy of the database your’re working with. Doing this allows you to restore the database if something goes wrong.
This shows you how to backup MySQL/MariaDB databases. If you’re using another database server, you may want to go and find resources on backing up databases from that server.
mysqldump -u root -p wpdatabase >> wpdatabase.sql
The commands above create a backup database in the working directory called wpdatabase.sql.
Changing WordPress user’s Password
Next, run the command to logon to the server
mysql -u root -p
You’ll be prompted for the root user password for MySQL.
Then run the commands below to change WordPress user’s password.
UPDATE `wp_users` SET `user_pass` = MD5('new_password_here') WHERE `wp_users`.`user_login` = "admin";
The statements above assume you’re using admin as the username. If you’re using something other than admin, replace admin with it and press Enter.
If you want to change WordPress user email address as well, run the statements below.
UPDATE `wp_users` SET `user_email` = "new_email_address" WHERE `wp_users`.`user_login` = "admin";
This is how to change a WordPress user password as well as his/her email address.
You may also like this tutorial: