---
title: "\"Error Establishing a Database Connection\" in WordPress"
description: This error indicates WordPress cannot connect to your database, usually due to incorrect credentials, database corruption, or server issues. Here’s how to troubleshoot and fix the issue.
---

[Skip to content](https://help.blakemarkdigital.co.uk/error-establishing-a-database-connection-in-wordpress#main-content)

English - United Kingdom

Show submenu for translations

[More support](https://help.blakemarkdigital.co.uk/kb-tickets/new) [Support Portal](https://help.blakemarkdigital.co.uk/support-portal)

[![Blake Mark Digital Logo](https://help.blakemarkdigital.co.uk/hs-fs/hubfs/Asset%205.png?width=200&height=57&name=Asset%205.png)](https://blakemarkproductions.com/)

Open main navigation

Close main navigation

- English - United Kingdom
  
  Show submenu for translations
- [More support](https://help.blakemarkdigital.co.uk/kb-tickets/new)
- [Support Portal](https://help.blakemarkdigital.co.uk/support-portal)
- [Contact Support](https://help.blakemarkproductions.com/support-portal)

[Contact Support](https://help.blakemarkproductions.com/support-portal)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge Base](https://help.blakemarkdigital.co.uk/)
2. [Web Hosting](https://help.blakemarkdigital.co.uk/web-hosting)
3. [WordPress](https://help.blakemarkdigital.co.uk/web-hosting#wordpress)

# "Error Establishing a Database Connection" in WordPress

This error indicates WordPress cannot connect to your database, usually due to incorrect credentials, database corruption, or server issues. Here’s how to troubleshoot and fix the issue.

### 1. **Check Database Credentials in** **`wp-config.php`**

Start by verifying the credentials stored in your WordPress configuration file.

- Login to cPanel.
- Open **File Manager** under the **Files** section.
- Navigate to your WordPress root directory (**usually** located in `/public_html/`).
- Find and open the `wp-config.php` file for editing.

Within the file, you’ll find entries like this:

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

 

**Take note** of the following values:

- `DB_NAME`: Your database name.
- `DB_USER`: The MySQL username.
- `DB_PASSWORD`: The password for that user.
- `DB_HOST`: This is typically set to `localhost` unless your hosting provider uses a different hostname for databases.

### 2. **Verify Database Details in cPanel**

Now that you’ve noted the database credentials from `wp-config.php`, you need to confirm that they match your actual database details.

- In cPanel, go to **MySQL Databases** under the **Databases** section.
- Look for the **Current Databases** section. 
    - Verify that the `DB_NAME` from `wp-config.php` matches an existing database in this list.
    - Check that the **User** assigned to this database matches the `DB_USER` in `wp-config.php`.

If any of these details don’t match, you’ll need to update them in the `wp-config.php` file to reflect the correct database name and username.

 

### 3. **Reset the MySQL User Password**

If the database details are correct, the issue might be with the database password. You can reset the MySQL user’s password and update it in `wp-config.php`.

**Steps:**

- In cPanel, go to **MySQL Databases**.
- Scroll down to the **Current Users** section.
- Find the MySQL user matching the `DB_USER` value in `wp-config.php`.
- Click **Change Password** next to the user and enter a new, strong password.

Now, update the `DB_PASSWORD` in your `wp-config.php` file with the new password:

```
define('DB_PASSWORD', 'new_password_here');
```

 

Save the changes in the file.

 

### 4. **Ensure MySQL User Has Proper Permissions**

The MySQL user needs the correct permissions to interact with the database. If the permissions are incorrect, the connection will fail.

**Steps:**

- In cPanel, under **MySQL Databases**, scroll to the **Add User to Database** section.
- Select the correct MySQL **User** and **Database** from the dropdown menus.
- Click **Add**.
- On the next screen, ensure **All Privileges** are selected, then click **Make Changes**.

This grants the MySQL user full access to the database, ensuring proper functionality.

- [Getting Started](https://help.blakemarkdigital.co.uk/getting-started)
- [Web Hosting](https://help.blakemarkdigital.co.uk/web-hosting#main-content)

    - [Elementor](https://help.blakemarkdigital.co.uk/web-hosting#elementor)
    - [WordPress](https://help.blakemarkdigital.co.uk/web-hosting#wordpress)
    - [Security](https://help.blakemarkdigital.co.uk/web-hosting#security)
- [Email](https://help.blakemarkdigital.co.uk/email#main-content)

    - [Mail Clients](https://help.blakemarkdigital.co.uk/email#mail-clients)
    - [SpamExperts](https://help.blakemarkdigital.co.uk/email#spamexperts)
    - [MailChannels](https://help.blakemarkdigital.co.uk/email#mailchannels)
- [Domains](https://help.blakemarkdigital.co.uk/domains#main-content)

    - [Domain Privacy](https://help.blakemarkdigital.co.uk/domains#domain-privacy)
- [Billing](https://help.blakemarkdigital.co.uk/billing)
- [cPanel](https://help.blakemarkdigital.co.uk/cpanel#main-content)

    - [JetBackup](https://help.blakemarkdigital.co.uk/cpanel#jetbackup)
    - [Softaculous](https://help.blakemarkdigital.co.uk/cpanel#softaculous)
- [WordPress Glossary Terms](https://help.blakemarkdigital.co.uk/wordpress-glossary-terms#main-content)

    - [H](https://help.blakemarkdigital.co.uk/wordpress-glossary-terms#h)

[![Blake Mark Digital Logo](https://help.blakemarkdigital.co.uk/hs-fs/hubfs/Asset%205.png?width=250&height=71&name=Asset%205.png "Blake Mark Digital Logo")](https://blakemarkdigital.co.uk/)

Blake Mark Digital is a digital marketing agency supporting SMEs and non-profits with strategic branding, content, and campaigns that drive real results

124-128 City Road, London, EC1V 2NX

[support@blakemarkdigital.co.uk](mailto:support@blakemarkdigital.co.uk)

+44 20 4578 9582

<https://www.facebook.com/blakemarkproductions> <https://www.instagram.com/blakemarkproductions/> <https://blakemarkproductions.com/podcast> [mailto:support@blakemarkproductions.com](mailto:support@blakemarkproductions.com)

Copyright © Blake Mark Productions Ltd