Updating WordPress database configuration settings
If your WordPress site shows the error “Error establishing a database connection”, it usually means the database configuration in wp-config.php does not match your actual database settings. On ruachost.com, you can fix this by updating the configuration file with the correct credentials.
Why Update Database Settings?
Section titled “Why Update Database Settings?”- Resolve connection errors after migrations or imports.
- Ensure WordPress can communicate with the correct database.
- Restore site functionality when credentials change.
Steps to Update Database Configuration
Section titled “Steps to Update Database Configuration”Step 1: Determine Correct Database Settings
Section titled “Step 1: Determine Correct Database Settings”-
Log in to cPanel from your ruachost.com hosting account.
-
Go to Databases → phpMyAdmin.
-
In the left panel, locate your WordPress database name.
- Typically formatted as
username_wpXXX.
- Typically formatted as
-
Click the database → Note the table prefix (usually
wp_). -
Return to Databases → MySQL Databases.
-
Note the database username associated with your WordPress database.
-
Reset the database user’s password if you don’t know it.
Step 2: Update wp-config.php
Section titled “Step 2: Update wp-config.php”-
In cPanel, go to Files → File Manager.
-
Navigate to your WordPress installation directory (usually
public_html). -
Locate and edit the wp-config.php file.
-
Update the following lines with your correct database details:
define('DB_NAME', 'username_wp123'); // Database namedefine('DB_USER', 'username_wpuser'); // Database usernamedefine('DB_PASSWORD', 'your_password'); // Database passworddefine('DB_HOST', 'localhost'); // Database host$table_prefix = 'wp_'; // Table prefix -
Save changes.
-
Visit your WordPress site → It should now load correctly.
Important Notes
Section titled “Important Notes”- Always back up your site before editing configuration files.
- Do not use weak passwords for database users.
- If your hosting environment uses a remote database server, replace
localhostwith the correct hostname. - Ensure the
$table_prefixmatches the prefix used in your database tables.