MySQL Connection Strings | Bluehost Support
Support
  1. bluehost knowledge base

MySQL Connection Strings

A connection string is a sequence of variables that will address the specific database and allow you to connect your code to your MySQL database.

If you do not have a database yet, the following article will provide you with the proper instructions: How to Create and Delete MySQL Databases and Users.



Configuration

Once you have a database setup, create the database's tables either via phpMyAdmin, MySQL software, or use an online PHP or Perl script.

Use the following configuration settings:

  • Version: MySQL 5
  • Username: cpUsername_dbUserName
  • Database Name: cpUsername_dbName
  • Password: The password for cpUsername_dbUsername
  • Host address: localhost
  • Port: 3306

For PHP Version 5.4

Connection String Examples

The connection string can be either of the two examples below (be sure to replace the variables in red with your actual information):

For Perl:

$dbh = DBI->connect("DBI:mysql:cpUsername_dbName:localhost","cpUsername_dbUsername","password");

For PHP:

$dbh=mysql_connect ("localhost", "cpUsername_dbUsername", "password")
or die ('I cannot connect to the database.');
mysql_select_db ("cpUsername_dbName");

Take Note: If you're using PHP version 5.6 and above, replace the mysql_connect with mysqli_connect. For more information on how-to work with phpMyAdmin. Please visit phpMyAdmin.net.

Contact Support

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.