How to change your WordPress database password?

Need to change the password for your WordPress database to a strong one? Just like your WordPress dashboard login password, you should choose a database password that is very difficult to be guessed or hacked. This guide will explain how to change WordPress database password from cPanel. There are 2 main steps required in order to update WordPress DB password, changing database password and then update your connection strings to use the new password. And they can be done from cPanel easily.

Steps to change WordPress database password

Log in your cPanel, go to Database Tools >> MySQL Databases. A new page opens where you can see all existing databases under the Current Databases section and databases users under the Current Users. Find out the database your WordPress site is running on and the privileged user that can access it. Go to the Current Users section, click Change Password to set a new password for the MySQL user account.

change mysql db user password in cpanel with bluehost

You can make use of the Password Generator to automatically choose a strong password for you. Make sure copy the new password somewhere for record. Hit the Change Password button to save it.

Update password in WordPress database connection string

Now we need to change the DB password in the wp-config.php file. In cPanel, click Files >> File Manager. Browse to the WordPress installation folder, find and right click on wp-config.php file, choose Edit or Edit code from the context menu to open the configuration file online. Before you make any change to it, you may save a copy of this file so you can recover it if you made any mistake. Once the file has opened, find section below:

/** MySQL database password */
define(‘DB_PASSWORD’, ‘oldpassword’);

Then replace the ‘oldpassword’ with the new database password you have just updated above. Save the change and close this file. Now you’ve successfully changed your WordPress database password and updated the WordPress configuration file accordingly. Go to visit any post or page of your site to ensure the site is working properly.

Create a new database user for WordPress

Other than updating password for an existing database user, you can also choose to create a new database user for your WordPress site from cPanel and add the new user to your WordPress database. For more details, you can refer to this guide to create MySQL database in cPanel. You can find instructions to create new DB user, add user to database and grant it permissions at the lower section of previous linked article.

If you choose to replace WordPress database user with a new one, do not forget to detach the old user from the database or delete it from your hosting control panel.

Leave a Reply

Your email address will not be published. Required fields are marked *