Resolving Database Connection Issues Print

  • 0

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

  1. Log into cPanel → File Manager → open your CMS config file (e.g., wp-config.php).
  2. Verify the database name, username, and password are correct.
  3. 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

  1. Go to cPanel → MySQL Databases.
  2. Assign your DB user to the correct database.
  3. Select All Privileges.
  4. 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

Was this answer helpful?

« Back