SQL Connection Strings

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

If you do not have a database created yet, the following article will provide you with the proper instructions:


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

Use the following configuration settings:

  • Version: MySQL 5
  • Username: cpUsername_dbName
  • Database Name: cpUsername_dbUsername
  • 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:cpuser_db:localhost","cpuser_dbuser","password");DBI->connect("DBI:mysql:cpUsername_dbNamelocalhost","cpUsername_dbUsername","password");

For PHP:

$dbh=mysql_connect ("localhost", "cpuser_dbuser", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("cpuser_db");

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