In this post, I wil show you how to update database configuration settings in Joomla. This is necessary when Joomla cannot connect to the database.
For example, if you migrate a Joomla site from another hosting provider, the database username is often different.
After following the procedures described below, you can make your site live (if some issue was caused due to database).
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. OR 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 file. 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 make the mismatch in the database specified in the configuration.php file and the actual database.
To resolve this issue, 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 steps given below.
Determine the correct MySQL database settings:
- Log in to cPanel.
- In the Databases scetion, click on phpMyAdmin.
- In the left-hand pane of phpMyAdmin, note the name of the Joomla database that you want to use.
- Click the name of the Joomla database that you want to use, then a list of tables in the database appears.
- In the Table column, note the table prefix that is used in the table names. Typically, the Joomla database table prefix is jos_. However, if your account was recently migrated, the table prefix may be different, or even nonexistent.
- Now in the Databases section of the cPanel home screen, click on MySQL® Databases.
- Under Current Databases, locate the database that you noted in step 3.
- Note the database username for the database. (If you do not know the password for this database user, you can reset it now).
Update the configuration.php file:
After you have determined the correct database settings, you are now ready to update the configuration.php file. To do this, follow the below steps:
- In the Files section of the cPanel home screen, click on File Manager.
- Navigate to the directory where Joomla is installed. Typically, Joomla is installed in the public_html (document root) directory. However, if you have installed Joomla in a subdirectory, navigate to that directory.
- Right-click the configuration.php file, and then click .
- 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 password@123, modify the text as follows:
public $password = ‘password@123’;
- 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’;
- Click .
That’s all. Now try to load your Joomla site and you will be able to view your site.
If you still face any issue regarding this, feel free to comment in the box given below. I will be more than happy to help you.
Powered by Facebook Comments