> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.ex2.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to connect to a MySQL database?

In order for the [MySQL](https://help.ex2.com/en/article/what-is-mysql-1keq6x7/?bust=1784209103272) [database](https://help.ex2.com/en/article/what-is-a-database-1re36hx/?bust=1784817086124) to work, you will first need either to use a calling script or to query the database for the information it stores. To do this, you need to connect your script to the database using a configuration file.

### What are my database configuration settings?

Platforms like WordPress, WHMCS, and Joomla usually have a default configuration file ready for you to edit with the appropriate information.

* Hostname = localhost
* Database name = cpanelUsername_databaseName
* Database user name = cpanelUsername_databaseUsername
* Database password = the password you associated with your username when creating it

###### In the example below, we will use the basic WordPress settings (wp-config.php file format).

* cPanel username = example-ex2
* Hostname = localhost
* Database name = testdbex2
* Database username = clientEx2
* Database password = 09Xm2Ltq%X-t

###### The code associated with our example: 

```
// ** MySQL Settings ** //
/** The name of the database for WordPress */
define('DB_NAME', 'exemple-ex2_testdbex2');

/** MySQL database username */
define('DB_USER', 'exemple-ex2_clientEx2');

/** MySQL database password */
define('DB_PASSWORD', '09Xm2Ltq%X-t');

/** MySQL hostname */
define('DB_HOST', 'localhost');
```