How do I connect to a MySQL database with a script using WHM/cPanel?

When installing a php script it’s typical for the script to ask for the following mysql information.  Normally it requires a new database, user, and password so that it can generate the tables for the database.

Mysql Host : localhost
Mysql User :
Mysql Pass :
Mysql DB:

Typically the ‘Mysql Host’ should be set to ‘localhost’.

You will need to create the new mysql user, pass, and DB.  Below are instructions on how to do this:

  1. Log into the desired cPanel account.
  2. Navigate to Mysql Databases under the Databases section
  3. Create a new database.
  4. Note the name of the database after you click the ‘Create Database’ button. You will see the database is named cpaneluser_databasename. cPanel will append the cPanel username to each database.
  5. Back at the Mysql Databases section, add a new user. The same applies to the username as does the database name. The user will be cpaneluser_user.
  6. In the main Mysql Databases screen, go to the Add User To Database section and select your new user and new database and click Add.
  7. At the next page, select All Privileges
  8. Click Make Changes.

Photo by Samuel M. Livingston

Find out more about ServInt solutions

Starting at $25

  • Hosting Advice
  • Computer World
  • Ars Technica

  • The New York Times
  • The Seattle Times
  • Bloomberg
  • The Hill

To engage with the ServInt Sales Team use the following chat icon. Normal sales hours are Monday-Friday 9am-5pm EST but feel free to leave a message and we will follow up as soon as possible.

Sales Chat

To engage with the ServInt Support Team you must be logged into our Customer Portal for identity verification and have a ticket opened about your request or there will only be limited support offered.

Support Chat