Home Web Hosting Troubleshooting MySQL Database Connection Errors in Shared Hosting

Troubleshooting MySQL Database Connection Errors in Shared Hosting

Last updated on Aug 08, 2025

Troubleshooting MySQL Database Connection Errors in Shared Hosting

**Description:**A step-by-step guide for shared hosting customers to diagnose and resolve common MySQL database connection issues—including checking credentials, resource limits, and service status—using tools available in cPanel.


Table of Contents


Introduction

MySQL database connection errors are among the most common issues for websites on shared hosting. These errors can occur for several reasons, but most problems can be resolved with a few straightforward checks in your cPanel account.


Common Causes of MySQL Connection Errors

  • Incorrect database name, username, or password
  • Insufficient user privileges
  • Database or user does not exist
  • Incorrect hostname in configuration
  • Database resource limits exceeded
  • Account suspension or restriction
  • Syntax errors in your application’s configuration file

Step-by-Step Troubleshooting Guide

1. Verify Database Credentials

Check that your application is using the correct database name, username, and password.

How to Check:

  1. Log in to cPanel.
  2. Go to MySQL Databases.
  3. Locate your database and user under “Current Databases” and “Current Users.”
  4. Compare these details with those in your website’s configuration file (e.g., wp-config.php for WordPress).

Example for WordPress:

// wp-config.php
define('DB_NAME', 'cpaneluser_dbname');
define('DB_USER', 'cpaneluser_dbuser');
define('DB_PASSWORD', 'your_db_password');
define('DB_HOST', 'localhost');

Tip: If you’re unsure about the password, use cPanel’s “Change Password” feature for your database user and update your configuration file accordingly.


2. Check Database User Privileges

The database user must have the correct privileges for the database.

How to Check:

  1. In cPanel > MySQL Databases, scroll to Add User To Database.
  2. Ensure your database user is assigned to your database.
  3. Click Manage User Privileges and confirm that the necessary privileges are checked (usually ALL PRIVILEGES).

3. Confirm Database Existence

Make sure the database and user exist and are spelled correctly in your configuration files.

How to Check:

  • In cPanel > MySQL Databases, look for your database and user in the lists.
  • If missing, create them as needed.

4. Ensure Correct Hostname

For most shared hosting environments, the MySQL hostname should be localhost.

  • In your configuration file, check that the database host is set as follows:

    define('DB_HOST', 'localhost');
    
  • Do not use an IP address or external hostname unless specifically instructed.


5. Review Resource Limits

Exceeded database resource limits (connections, queries) can cause connection errors.

How to Check:

  • In cPanel > Resource Usage (or CPU and Concurrent Connection Usage), review for recent faults or limits reached.
  • If you consistently hit limits, consider optimising your application, disabling resource-heavy plugins, or upgrading your hosting plan.

6. Check for Suspensions or Restrictions

Account suspensions or restrictions (due to abuse, overdue invoices, etc.) can disable MySQL access.

How to Check:

  • Log in to your Brixly client area and check for any account alerts or suspension notices.
  • If your account is suspended, follow the instructions provided or contact support.

7. Investigate Application Configuration Files

Typos, incorrect formatting, or misplaced characters in configuration files can break database connections.

How to Check:

  • Use cPanel > File Manager to view and edit your configuration files (e.g., wp-config.php, .env, config.php).
  • Look for syntax errors or blank spaces.

Example of a correct .env entry:

DB_DATABASE=cpaneluser_dbname
DB_USERNAME=cpaneluser_dbuser
DB_PASSWORD=your_db_password
DB_HOST=localhost

Common Error Messages and What They Mean

Error Message Likely Cause Suggested Action
Access denied for user... Wrong username or password, missing privileges Reset password, check privileges
Unknown database... Database name is incorrect or missing Verify database name, create if missing
Can't connect to local MySQL server... Hostname incorrect, MySQL service issue Use localhost as host, check service status
Too many connections / User ... has exceeded... Resource limits exceeded Optimise app, reduce plugins, consider upgrade
Connection timed out Hostname incorrect, firewall, or server issue Use localhost, check for suspensions

When to Contact Support

If you have followed all the above steps and still experience issues:

  • Submit a support ticket from your Brixly client area.
  • Include:
    • The exact error message
    • The steps you’ve already taken
    • Your domain and affected database/user

Support tickets help us resolve your issue efficiently and securely.


Further Reading


By following these steps, most MySQL connection errors on shared hosting can be diagnosed and resolved without server admin access. If you need extra help, our support team is always ready to assist!