HostMonster Web Hosting Help

MySQL Connection Strings


A connection string is a sequence of variables which 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


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
  • Hostaddress: localhost
  • Port: 3306

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");

For more information on how to work with phpMyAdmin. please visit:

Knowledgebase Article 64,127 views bookmark tags: connection databases mysql (updated 453 days ago)

Was this resource helpful?

Did this resolve your issue?

Please add any other comments or suggestions about this content:

Recommended Help Content

I get the following database connection error: Warning: mysql_connect() [function.mysql-connect]: Host '' is blocked because of many connection errors; unblock with 'mysqlad (updated 1822 days ago)
Knowledgebase Article 99,812 views tags: blocked connection host mysql

This article will go over different application available for remote connection to your databases. (updated 824 days ago)
Knowledgebase Article 43,032 views tags: database mysql

This article will explain how to connect your scripts to your MySQL databases. (updated 819 days ago)
Knowledgebase Article 25,335 views tags: database mysql scripts

Related Help Content

Users having problems connecting to mysql database using SSH and/or putty/other client. (updated 1723 days ago)
Knowledgebase Article 60,047 views tags: connection ip mysql putty ssh whitelist

This article will explain MySQL database and user creation and deletion, and explain how to assign a user to a database. (updated 52 days ago)
Knowledgebase Article 449,963 views tags: creation database mysql

This article will show a few MySQL errors along with explanations as to why they might be occurring. (updated 817 days ago)
Knowledgebase Article 13,440 views tags: errors mysql

How to backup all of your MySQL databases using the Site Backup & Restore tool (updated 1354 days ago)
Knowledgebase Article 57,791 views tags: backup database mysql restore site

How to restore MySQL databases using the Site Backup & Restore tool (updated 1221 days ago)
Knowledgebase Article 44,525 views tags: backup database mysql restore site

How to restore MySQL databases using the Site Backup & Restore tool (updated 994 days ago)
Knowledgebase Article 55,971 views tags: backup database mysql restore site

Optimizing MySQL: Queries and Indexes Article 2 of 4 Courtesy of: Ian Gilfillan Some knowledge of how indexes work allows you to use them more efficiently. Firstly, note that when you update a table w (updated 1332 days ago)
Knowledgebase Article 82,116 views tags: indexes mysql optimize optimizing queries query

This article will instruct you how to export a database from the command line (SSH). (updated 597 days ago)
Knowledgebase Article 426,233 views tags: database mysql ssh