Fixing Database Connection Issues
Troubleshoot “Error establishing database connection” in cPanel-hosted websites.
Causes
- Incorrect database name, username, or password
- User not assigned to the database or missing privileges
- Database not imported or missing tables
- Server or MySQL connectivity issues
Check Database Credentials
- Log into cPanel → File Manager → open your CMS config file (e.g.,
wp-config.php). - Verify the database name, username, and password are correct.
- Fix any typos → save → test site again.
Tip: Most DB connection errors come from mismatched credentials.
Verify Database in phpMyAdmin
- Open phpMyAdmin → select your database.
- Check if all tables exist.
- If missing or empty → import your SQL backup.
- Confirm the import completed without errors.
Update CMS Config
- Ensure database host is correct — normally
localhost. - Verify table prefix (e.g.,
wp_for WordPress). - Save config → reload website.
Check User Privileges
- Go to cPanel → MySQL Databases.
- Assign your DB user to the correct database.
- Select All Privileges.
- Test DB connection again.
Warning: Without correct privileges, your CMS cannot read or write database tables.
Checklist
- [ ] Verify DB name, username, password - [ ] Check tables in phpMyAdmin - [ ] Update CMS config file - [ ] Assign DB user privileges - [ ] Test DB connection - [ ] Reload site and verify© Database Connection Guide