GridPane is pleased to announce that we’ve accepted a strategic investment from Automattic Read all about it

Change password of a database user

1 min read

In the highly unlikely event that you need to change the password of a website’s database, this article will walk you through how to do so. 

For this, you’ll need to connect to your server – if this is your first time, please see the following articles to get started:

Step 1. Login to MySQL

The following command will directly log you into MySQL. Simply copy and paste it and hit enter:

gp mysql login root

Step 2. Update your Site’s MySQL User Password

Copy and paste the following, and edit the highlighted parts in red to match your website’s database user name and the new password you want to set (you can view this inside your wp-config.php file inside your websites customizer):

ALTER USER 'website-db-user-here'@'localhost' IDENTIFIED BY 'new-password-here';

Exit MySQL with:

exit

Step 3. Update your wp-config.php file

Your wp-config.php file exists inside your websites root directory. You can edit it with the following command (replacing “site.url” with your website’s URL):

nano /var/www/site.url/wp-config.php

Edit this section:

/** MySQL database password */
define( 'DB_PASSWORD', 'XXXXXXXXXXXXXXXXXXXXXXX' );

Then save the file with CTRL+O followed by Enter. Exit nano with CTRL+X.

Your website’s database password has now been updated. Visit your website and confirm all is working correctly.

Step 4. Reset PHPMyAdmin Credentials

To finish up, you’ll now need to run the following command to update PHPMyAdmin (replace site.url with your actual site URL):

gp site site.url -dbcreds