If you are using assistive technology and are unable to read any part of the HostMonster website, or otherwise have difficulties using the HostMonster website, please call 866-573-HOST and our customer service team will assist you.
Skip to main content

HostMonster Web Hosting Help

MySQL Connection Strings

Summary

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


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
  • 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: phpMyAdmin.net.

Knowledgebase Article 152,141 views bookmark tags: connection databases mysql


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 'host#.HostMonster.com' is blocked because of many connection errors; unblock with 'mysqlad
Knowledgebase Article 159,400 views tags: blocked connection host localhost mysql

This article will explain how to connect your scripts to your MySQL databases.
Knowledgebase Article 120,067 views tags: database mysql scripts

This article will go over different application available for remote connection to your databases.
Knowledgebase Article 119,873 views tags: database mysql

Related Help Content

This article will explain MySQL database and user creation and deletion, and explain how to assign a user to a database.
Knowledgebase Article 665,032 views tags: creation database mysql

How do I remotely connect using a database management software?
Knowledgebase Article 829,138 views tags: connection database mysqlfront remote

Can I make multiple IMAP connections to the same email address?
Knowledgebase Article 130,373 views tags: connections imap limit

This article will show a few MySQL errors along with explanations as to why they might be occurring.
Knowledgebase Article 59,491 views tags: errors mysql

How to restore MySQL databases using the Site Backup & Restore tool
Knowledgebase Article 110,057 views tags: backup database mysql restore site

This article will explain how to change or reset the password for a MySQL user.
Knowledgebase Article 48,954 views tags: change mysql password reset user

How to backup all of your MySQL databases using the Site Backup & Restore tool
Knowledgebase Article 114,533 views tags: backup database mysql restore site

This article will show you how to rename a database table in phpMyAdmin.
Knowledgebase Article 176,757 views tags: databases mysql phpmyadmin

This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here