MySQL Admin WordPress Password Change Tutorial

Have you ever forgotten your WordPress admin password and not having access to your email or not properly logging into your WordPress email account? Do not worry. Here’s how to change your password through the MySQL command line .

This will be very easy if you have a database connection username and password or access the wp-config.php file.

Reset your WordPress admin password using MySLQ

Let’s start by searching for the username and password of the WordPress database that you have stored in the wp-config.php file. We do this by going to the directory where you have WordPress installed and opening the file with an editor like Nano.

# nano wp-config.php

Find the following lines in the wp-config.php file:

Fields written as Username_here or similar contain your account information instead. And in the queries section, you need to correctly replace these expressions with the information in the table.

Now we have all the information needed to connect to the WordPress database and we can connect to the database with the following information.

After executing the above command it will ask you for a password. Enter the password from the location  password_here.

After accepting the password, enter the following database query . Replace the wordpress database name from the wp-config.php file information here.

Using the following query you can find a table that is related to management by replacing its name.

The table output will be similar to the following table.

You can select a user from the default user table that has high query output. For example, we chose wp_users. We also use admin for our admin name. Your admin or admin name may be different that you need to replace admin.


As you can see above the query output is a table with the administrator’s password written in encrypted or hashed in front of it.

Use the lower query to change the administrator password. Of course, this password must be encrypted, which is hashed by the same query with the MD5 algorithm.

In the new_password section, enter your new password.

Now if you test the password you will notice that the password has changed.

Enter exit to exit MySQL.

Note: If you have PHP My Admin you can use the graphical interface of this software to easily view and change the password. Which will be taught in the next section.

Hope you found this helpful.

Related posts