What this problem is
You need to update WordPress database credentials (after password rotation, migration, or host change).
Prerequisites
- FTP/File Manager access to edit
wp-config.php - Hosting panel access to view/create database users
Diagnosis
If the site shows a database connection error, confirm the current DB credentials in the hosting panel match the file.
Detailed steps
Step 1) Locate wp-config.php
It is in the WordPress root (same level as wp-content).
Step 2) Update the database constants
define("DB_NAME", "database_name");
define("DB_USER", "database_user");
define("DB_PASSWORD", "database_password");
define("DB_HOST", "localhost");
Step 3) Confirm DB user privileges
Ensure the DB user has permissions on the WordPress database (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX).
Step 4) Test
Load the site and wp-admin. If it fails, re-check DB_HOST and password.
Expected results
- WordPress connects to the database and loads normally
What to do if it fails
- Try the exact DB_HOST provided by your host (sometimes not localhost)
- Reset the database user password in the hosting panel and update wp-config.php again
Best practices
- Rotate passwords periodically and store them securely
- Limit database user privileges to only what WordPress needs