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 this article.

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.

Create a Database - Windows plans

In order to setup your database correctly, you can use the tutorials listed below:

Create MySQL database in SolidCP

How to manage a database in Plesk

In the most common applications, such as Joomla! and WordPress, 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 toproperly 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.


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


Connection string is located in wp-config.php

/** The name of the database for WordPress */ define('DB\_NAME', 'database\_name\_here'); /** MySQL database username */ define('DB\_USER', 'username\_here'); /** MySQL database password */ define('DB\_PASSWORD', 'password\_here'); /** MySQL hostname */ define('DB\_HOST', 'database\_host\_here');

Please note that in most cases, 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 SolidCP, you will find the Databasehost in the Space summary or in Plesk control panel for Windows based VPS/Cloud users that are using Plesk instead of SolidCP.