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.
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.
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.
To determine the correct MySQL database settings, follow these steps:
The phpMyAdmin administration page appears in a new window.
In the left-hand pane of phpMyAdmin, note the name of the Joomla database that you want to use.
In the Table column, note the table prefix that is used in the table names.
In the DATABASES section of the cPanel home screen, click MySQL® Databases:
Note the database username for the database.
After you have determined the correct database settings, you are ready to update the configuration.php file. To do this, follow these steps:
Navigate to the directory where Joomla is installed.
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';
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';
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';
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_';
If your database does not use a table prefix, modify the text as follows:
public $dbprefix = '';
Confirm that the $host variable is set to localhost as follows:
public $host = 'localhost';
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.