The WordPress Error Establishing Database Connection is a common issue that occurs when WordPress cannot connect to the database server. This can happen if the database credentials in the wp-config.php file are incorrect or do not match the actual database information. To fix this error, you can try the following steps:

  • Check your wp-config.php file: The wp-config.php file is a configuration file that contains important WordPress settings, including the database name, username, password, and host. You can find this file in the root directory of your WordPress installation. You can access it using FTP or cPanel File Manager. You need to make sure that the values of these constants are correct and match the database information provided by your hosting provider:
PHP

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** MySQL database username */
define( 'DB_USER', 'username_here' );

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

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
  • Create a new database user and password: Sometimes, the database user or password may be corrupted or changed by mistake. In that case, you can create a new database user and password and assign them to your WordPress database. You can do this using cPanel or phpMyAdmin. You need to make sure that the new user has all the privileges to access and modify the database. After creating the new user and password, you need to update the wp-config.php file with the new credentials.
  • Contact your hosting provider: If none of the above steps work, then the problem may be on the server side. Your hosting provider may have changed the database server address, or the database server may be down or overloaded. In that case, you need to contact your hosting provider and ask them to check the database server status and the database connection details. They may be able to fix the error or provide you with the correct information to update your wp-config.php file.

We hope this tutorial was helpful to you. If you have any questions or feedback, please let us know.

Categorized in: