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.

Tips and Tricks for Moving Databases
  • When you move databases to our servers, the database name and username may change. This change must be updated in your script code. (The database name and username is clearly displayed in cPanel, in the MySQL area.)
  • On Shared servers, the database username cannot be changed to something without the cPanel username in it. This is to keep database names and usernames from conflicting with others on the server.

MySQL User Has No Privileges

Since the 11.25 update, we've noticed an occasional bug where adding an IP to the MySQL remote access list results in the corresponding MySQL user having no privileges.

In order to get the correct privileges added:

  1. Go to your MySQL Databases in cPanel.
  2. Re-add the user to each database by selecting the user and the database from the drop-down menus.
  3. Reassign the privileges.
  4. Click Add.

We have notified cPanel about the issue in hopes of this bug being corrected in newer updates.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Log into cPanel

cPanel is a web hosting account management tool available on Linux hosting plans, including...

How do I deny IP address access?

How do I deny IP address access? Do you want to stop someone from visiting your website? This...

Viewing Your Disk Space Usage

Viewing Your Disk Space Usage To view the disk space usage totals for your account's...

Requesting a New cPanel Password

If you have lost or forgotten your cPanel password, you can reset it using any one of the methods...

How to Change the Password of An E-mail Account

How to Change the Password of An E-mail Account You can make changes to your email account...