Articles on: Files Management
This article is also available in:

How to connect to a MySQL database?

In order for the MySQL database 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');

Updated on: 22/03/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!