Database Connection Errors

A database connection error stops WHMAZ entirely. Work through these in order.

1. Verify the credentials

Open application/config/database.php and check the hostname, username, password and database name. Then test them independently of WHMAZ:

mysql -u your_db_user -p -h your_db_host your_db_name

If that fails, the problem is with the database or the credentials, not with WHMAZ.

2. Check the database server is running

systemctl status mysql

Use mariadb in place of mysql if that is what you run.

3. Check the user's privileges

The WHMAZ database user needs full privileges on its own database. A user that can connect but not read will produce confusing partial failures rather than a clean error.

4. Check the host value

  • For a database on the same server, localhost connects over a Unix socket and 127.0.0.1 connects over TCP. They are not interchangeable, and permissions are frequently granted for only one.
  • For a remote database, the user must be permitted to connect from your web server's IP address, and the firewall must allow port 3306.

5. "Too many connections"

The server has hit max_connections. Something is usually leaking connections, or the limit is simply too low for your traffic. Raise it in the MySQL configuration and restart, then investigate what exhausted it.

After a migration

Moving to a new server is the most common trigger. Recreate the database user on the new host and grant it privileges — importing a dump does not bring users and grants with it.

Was this article helpful?