This article describes how to update database configuration settings in WordPress. You may need to do this if WordPress cannot connect to the database.
When you try to view a WordPress site, you may receive the following error message:
Error establishing a database connection
This error occurs when WordPress is unable to connect to the specified database in its configuration settings. This usually occurs because the WordPress database configuration settings in the wp-config.php file are incorrect. For example, an account migration or WordPress database import can cause the database specified in the wp-config.php file and the actual database to differ.
To resolve this problem, first determine the correct MySQL database settings. Then you can update the wp-config.php file with the correct database settings. To do this, follow the procedures below.
To determine the correct MySQL database settings, follow these steps:
The phpMyAdmin administration page appears in a new window.
In the left-hand pane of phpMyAdmin, note the name of the WordPress database that you want to use.
In the Table column, note the table prefix that is used in the table names.
In the DATABASES section of the cPanel home screen, click MySQL® Databases:
Note the database username for the database.
After you have determined the correct database settings, you are ready to update the wp-config.php file. To do this, follow these steps:
Navigate to the directory where WordPress is installed.
Locate the DB_NAME setting, and then replace the value with the name of the WordPress database that you obtained in the previous procedure. For example, if your database name is username_wp123, modify the text as follows:
Locate the DB_USER setting, and then replace the value with the database username that you obtained in the previous procedure. For example, if your database username is username_wpuser, you would modify the text as follows:
Locate the DB_PASSWORD setting, and then replace the value with the database user's password. For example, if your database user's password is example_password, modify the text as follows:
Confirm that the DB_HOST setting is set to localhost as follows:
Locate the $table_prefix setting, and then replace the value with the database table prefix that you obtained in the previous procedure. For example, if the database table prefix is wp_, modify the text as follows:
$table_prefix = 'wp_';
If your database does not use a table prefix, modify the text as follows:
$table_prefix = '';
Usamos cookies para personalizar o site para você e para analisar o uso do nosso site. Você demonstra que concorda com isso ao clicar em "Eu concordo" ou ao continuar usando este site. Mais informações sobre cookies podem ser encontradas em nossa Política de privacidade.