• Wednesday, February 25, 2026

Knowledge Base

Database Connection Errors

Database Connection Problems

Database connection errors typically display messages like "Error establishing database connection" or "Could not connect to database."

Common Error Messages

  • Error establishing a database connection
  • MySQL server has gone away
  • Access denied for user
  • Unknown database
  • Too many connections

Troubleshooting Steps

1. Verify Database Credentials

Check your configuration file has correct details:

  • WordPress: wp-config.php
  • Look for DB_NAME, DB_USER, DB_PASSWORD, DB_HOST

2. Check Database Exists

In DirectAdmin:

  1. Go to MySQL Management
  2. Verify the database name exists
  3. Check the user is assigned to the database

3. Verify Username Format

DirectAdmin prefixes database names and users with your account name:

  • Database: username_dbname
  • User: username_dbuser

Make sure your config file uses the full prefixed names.

4. Reset Database Password

If unsure of the password:

  1. Go to MySQL Management
  2. Click on the database user
  3. Set a new password
  4. Update your website's configuration file

5. Check Database Host

The database host should typically be:

  • localhost (most common)
  • Or the specific MySQL server hostname if provided

6. Repair Database (WordPress)

Add to wp-config.php temporarily:

define('WP_ALLOW_REPAIR', true);

Then visit: yourdomain.com/wp-admin/maint/repair.php

Remove this line after repair!

Too Many Connections

This usually indicates your site is receiving heavy traffic or has a connection leak. Consider optimizing your code or upgrading your hosting plan.