“Error establishing a database connection” means WordPress can’t reach MySQL. The site is dead until this is fixed. The database itself is almost always fine. The problem is usually incorrect credentials in wp-config.php.

Step 1: Check wp-config.php Credentials

Open wp-config.php in your site root (via cPanel File Manager or SSH) and find these four lines:

  define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');
  

Each value must match exactly what’s configured in cPanel. Check them:

Verify Database Name

  1. Go to cPanel > MySQL Databases
  2. Scroll to Current Databases
  3. Confirm the database name matches DB_NAME in wp-config.php

Note: cPanel prefixes database names with your username. If your cPanel username is gozen, your database is gozen_wordpress, not just wordpress.

Verify Database User

  1. Same page: MySQL Databases > Current Databases
  2. Check which user is assigned to the database
  3. Confirm it matches DB_USER in wp-config.php

Same prefix rule applies: gozen_wpuser, not wpuser.

Verify Password

If you’re unsure of the password:

  1. Go to MySQL Databases
  2. Scroll to Current Users
  3. Click Change Password next to the database user
  4. Set a new password
  5. Update wp-config.php with the new password

Verify DB_HOST

On GoZen Host shared and managed VPS plans, DB_HOST should be localhost. If you see an IP address or a remote hostname, change it to localhost (unless you’re running a remote database server).

Step 2: Check if MySQL is Running

Shared Hosting

You can’t restart MySQL on shared hosting. If the database server is down, it affects all accounts on the server. Contact support - we’ll see it on our monitoring and fix it.

VPS / Dedicated Server

  sudo systemctl status mysql
# or
sudo systemctl status mariadb
  

If it’s not running:

  sudo systemctl start mysql
  

If it won’t start, check the MySQL error log:

  tail -50 /var/log/mysql/error.log
  

Common causes: disk full, corrupted InnoDB tablespace, or out of memory.

Step 3: Check Database Integrity

If credentials are correct and MySQL is running, the database might be corrupted.

Using wp-config.php

Add this line to wp-config.php (before the “stop editing” line):

  define('WP_ALLOW_REPAIR', true);
  

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

Click Repair Database (or Repair and Optimize for a more thorough fix).

Using phpMyAdmin

  1. Go to cPanel > phpMyAdmin
  2. Select your WordPress database
  3. Click Check All to select all tables
  4. From the dropdown at the bottom, select Repair table

Step 4: After a Migration

If this started happening after migrating to GoZen Host, the most common cause is the cPanel username prefix.

Your old host might have used database name wordpress with user wpuser. On GoZen, those become cpanelusername_wordpress and cpanelusername_wpuser.

Update all four values in wp-config.php to match the GoZen cPanel prefix.

What to Do Next

Last updated 07 Apr 2026, 00:00 +0200. history

Was this page helpful?