Symptoms
WordPress website on a Plesk server is not accessible with the following error:
Error establishing a database connection
Cause
Database connection credentials do no match the ones in the configuration file.
Resolution
Update the database password using the following procedure:
-
Go to Domains > example.com > File Manager and find the
wp-config.php
file in the domain directory. -
Open
wp-config.php
and find the first lines defining the database, database user, database password and database server address, like the following:/** The name of the database for WordPress /
define('DB_NAME', 'dbname');
/* MySQL database username /
define('DB_USER', 'username');
/* MySQL database password */
define('DB_PASSWORD', 'password');
/** MySQL hostname */
define('DB_HOST', '203.0.113.2:3306'); -
Copy the password (without the
''
symbols). -
Go to Domains > example.com > Databases and click the database user
username
under the databasedbname
(see lines fromwp-config.php
from the previous step for reference). -
Paste the password (see step 2) to the New password and Confirm password fields and click OK or Apply.
Note: In case an error is shown 'Database user name is greater than 16 characters', shorten the user name to under 16 characters on the Database User page in Plesk, and then update the
username
inwp-config.php
accordingly. -
Ensure that
DB_HOST
is set to the hostname or IP address displayed in Domains > example.com > Databases