What is Error establishing a database connection?

You may encounter a database error when accessing your WordPress website. Here are the common reasons why you are getting the error establishing a database connection message:

  • wrong database password
  • wrong database name
  • wrong database username

error-establishing-database-connection

How to fix error establishing a database connection?

via cPanel

Step 1. Log in to your cPanel.

cPanel-Login-SS

Step 2. For cPanel,  click File Manager under Files panel.

file1

Step 3. Locate WordPress directory.

Step 4. Click on wp-config.php.

wp-config

Step 5. Click on Code Editor.

code-editor-cpanel

Step 6. Read the guidelines and click Edit button.

edit-wp-config-cpanel

Step 7. In the editor page, locate the database name, username and password.edit-wp-config-php

Check the database credentials and make sure all are correct. Modify all the necessary credentials and update it.

Step 8. Click Save Changes button located at the upper right hand corner of the page.

save-wp-config

 

via FTP

Step 1. Access FTP.

Step 2. Locate WordPress directory.

Step 3. Click on wp-config.php and download.

Step 4. Access the file via editor.

Step 5. Locate the database name, username and password.

// ** MySQL settings – You can get this info from your web host ** //

/** The name of the database for WordPress */

define(‘DB_NAME’, ‘databasename’);

/** MySQL database username */

define(‘DB_USER’, ‘databaseusername);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘databasepassword);

Step 6. Save the wp-config.php file and upload it into your WordPress directory. You may need to overwrite the existing wp-config file.

Do not hesitate to contact our support team if you have further questions.

Error establishing a database connection

(Visited 38 times, 1 visits today)