> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting database connection errors in Joomla 3.0

> When you try to view a Joomla site, you may receive an "Error displaying the error page" message. Learn how to resolve this problem in this article.

This article describes how to update database configuration settings in Joomla. You may need to do this if Joomla cannot connect to the database.

For example, if you migrate a Joomla site from another host, the database username is often different. By following the procedures described below, you can restore database access to your site.

## Problem

When you try to view a Joomla site, you may receive the following error message:

```
Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.
```

Alternatively, you may receive an error message that resembles the following:

```
Error displaying the error page: Application Instantiation Error: SQL=SELECT `session_id` FROM `jos_session` WHERE `session_id` = 'ca3v...34' LIMIT 0, 1
```

These errors occur when Joomla is unable to connect to the specified database in its configuration settings. This usually occurs because the database configuration settings in the *configuration.php* file are incorrect. For example, an account migration or Joomla database import can cause the database specified in the *configuration.php* file and the actual database to differ.

## Resolution

To resolve this problem, first determine the correct MySQL database settings. Then you can update the Joomla *configuration.php* file with the correct database settings. To do this, follow the procedures below.

### Step 1: Determine the correct MySQL database settings

To determine the correct MySQL database settings, follow these steps:

1. Log in to cPanel.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. In the **DATABASES** section of the cPanel home screen, click **phpMyAdmin**:\
   ![cPanel - Databases - phyMyAdmin icon](https://static.hosting.com/kb/kb-cpanel-78-databases-phpmyadmin-icon.png)

   The phpMyAdmin administration page appears in a new window.

3. In the left-hand pane of phpMyAdmin, note the name of the Joomla database that you want to use.

   > 👍 Tip
   >
   > Typically, the Joomla database is **username\_joomXXX** , where *username* > represents your cPanel username, and *XXX* > is a three-digit number. However, if your account was recently migrated (for example, from another hosting provider), the database name may be in a different format.

4. Click the name of the Joomla database that you want to use. A list of tables in the database appears.

5. In the **Table** column, note the table prefix that is used in the table names.

   > 👍 Tip
   >
   > Typically, the Joomla database table prefix is **jos\_** . However, if your account was recently migrated (for example, from another hosting provider), the table prefix may be different, or even nonexistent.

6. On the **Tools** page, in the **Databases** section, click **Manage My Databases**:\
   ![cPanel - Databases - Manage My Databases icon](https://static.hosting.com/kb/kb-cpanel-120-databases-manage-my-databases-icon.png)

   > 📘 Note
   >
   > If you are using cPanel version 118 or earlier, click **MySQL Databases** instead:\
   > ![cPanel - Databases - MySQL Databases icon](https://static.hosting.com/kb/kb-cpanel-jupiter-databases-mysql-databases-icon.png)

7. Under **Current Databases**, locate the database that you noted in step 3.

8. Note the database username for the database.

   > 🚧 Important
   >
   > If you do not know the password for this database user, you should reset it now.

### Step 2: Update the configuration .php file

After you have determined the correct database settings, you are ready to update the *configuration.php* file. To do this, follow these steps:

1. In the **FILES** section of the cPanel home screen, click **File Manager**:\
   ![cPanel - File Manager icon](https://static.hosting.com/kb/kb-cpanel-78-file-manager-icon.png)

2. Navigate to the directory where Joomla is installed.

   > 👍 Tip
   >
   > Typically, Joomla is installed in the *public\_html* > (document root) directory. However, if you installed Joomla in a subdirectory, navigate to that directory instead.

3. Right-click the **configuration.php** file, and then click **Edit**.

4. Locate the **\$db** variable, and then replace the value with the name of the Joomla database that you obtained in the previous procedure. For example, if your database name is *username\_joom123*, modify the text as follows:

   ```
   public $db = 'username_joom123';
   ```

5. Locate the **\$user** variable, and then replace the value with the database username that you obtained in the previous procedure. For example, if your database username is *username\_joomuser*, modify the text as follows:

   ```
   public $user = 'username_joomuser';
   ```

6. Locate the **\$password** variable, and then replace the value with the database user's password. For example, if your database user's password is *example\_password*, modify the text as follows:

   ```
   public $password = 'example_password';
   ```

   > 🚧 Important
   >
   > It should go without saying that you should **not** use *example\_password* > as a password on a real installation!

7. Locate the **\$dbprefix** variable, and then replace the value with the database table prefix that you obtained in the previous procedure. For example, if the database table prefix is \_jos\_\_, modify the text as follows:

   ```
   public $dbprefix = 'jos_';
   ```

   > 📘 Note
   >
   > If your database does not use a table prefix, modify the text as follows:
   >
   > ```
   > public $dbprefix = '';
   > ```

8. Confirm that the **\$host** variable is set to **localhost** as follows:

   ```
   public $host = 'localhost';
   ```

9. Click **Save Changes**.

10. Use your web browser to go to the Joomla site's URL. The site should load.

## Related articles

* [Adding CAPTCHA protection to a Joomla site](/docs/adding-captcha-protection-to-a-joomla-site)

* [Disabling plugins in Joomla](/docs/disabling-plugins-in-joomla)
