How to set a Database Connection string for your Application
Before you can install any application, that is using a database,
it is strongly recommended that you create a Database with the proper Username, and Password from
your control panel.
You also need to setup the proper hostname (Please,
check the bottom of this article for IMPORTANT information on hostname)
for your database, more information which is available at the bottom of
Failing to setup the right database settings will often result in MySQL error such as:
"Error establishing database connection" - which will be displayed in your web browser.
In order to setup your database correctly , you can use the tutorials listed
Create Database, User and Password in cPanel (Linux Accounts)
Create MySQL database in SolidCP
Create MS SQL database in SolidCP
In the most common applications, such as Joomla!
a typical Connection string contains four mandatory attributes as follows:
1. Database Host
2. Database Name
3. Database Username
4. Database Password
All those attributes must be specified correctly in order to
properly connect the Database to the application used.
Below you will find samples of the Connection strings of Joomla!
and Wordpress, that will give you idea of a properly set configuration.
Joomla! : Connection string is located in configuration.php
public $host = 'database_host_here';
// This is the DB host
public $user = 'username_here';
// DB username
public $password = 'password_here';
// DB password
public $db = 'database_name_here';
// DB database name
WordPress : Connection string is located in wp-config.php
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
note that in most cases, both Linux and Windows based shared hosting
plans are using External Database servers and you should NOT
leave your database hostname to "localhost". For VPS/Cloud based
accounts you might be able to use the default "localhost" as database
server, but this needs to be verified using the information below.
For Linux based plans, you will find the EXACT Database
hostname under the Database section (Click on MySQL Databases) in cPanel control panel or Plesk panel (VPS/Cloud users using Plesk panel).
For Windows based plans, you will find the Database
host in the Space summary or in Plesk control panel for Windows based VPS/Cloud users that are using Plesk instead of SolidCP.