How to Connect to the MySQL Database?

In order for your MySQL database to work as intended, it will need a script calling or querying the database for the information it stores. In order to do this, you must connect your script to the database with a configuration file.

Configuration Settings

Database driven scripts, such as Wordpress, WHMCS and Joomla, will generally have a default configuration file ready for you to edit with the appropriate information. Below you will find examples of what this access information will look like:

Host Name = localhost (literally input localhost)
Database Name = cpanelUsername_databaseName
Database Username = cpanelUsername_databaseUsername
Database Password = whatever you selected

WordPress Example

Username = joe1337 Database Name = wrdp1
Database-Username = wp1 Database-User Password = eHTb7%Pxa9
// ** MySQL Settings ** //
/** The name of the database for WordPress */
define('DB_NAME', 'joe1337_wrdp1');

/** MySQL database username */
define('DB_USER', 'joe1337_wp1');

/** MySQL database password */
define('DB_PASSWORD', 'eHTb7%Pxa9');

/** MySQL hostname */
define('DB_HOST', 'localhost');
While it is possible to connect to the database using your cPanel username and password, we NEVER recommend this. Every time you change or reset your cPanel password your databases will stop working until configuration files are updated.
  • mySQL, database, SQL, php hosting, web hosting
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to find cPanel username & Password?

To find any web hosting account's information like username/password, just login to your client...

Login to cPanel

If you know the right username and password for your cPanel hosting account with us you may login...

Upgrade/Downgrade Account

To upgrade or downgrade a hosting account go to Services > My Services > View Details [for...

What is a Subdomain Name? How Do I Create and Delete One?

It is not always necessary to register a new domain name when the one you already own will work...

How to Generate/Download a Full Backup?

A full cPanel backup makes a copy of all of your files, email, databases, etc. Once initiated,...

Powered by WHMCompleteSolution