MySQL Database Setup & Administration

MySQL Initial Setup

If your hosting plan includes one or more MySQL databases, you must first create the databases before you can use them. Follow these steps to get started with MySQL.

Choose Services in the left column.

Locate MySQL in the services list and click the “pencil” button next to it as shown:

Services List

Click the “Change Password” tab.

Change Password

Enter a complex password to be used as your database administrator password. We recommend using the same complex password that was sent in your welcome email.

Now you are ready to create your database.

Creating A Database

Click the “Create Database” tab.

Create Database

Your database names have a fixed prefix, usually your domain name with an underscore substituted for the dot, as shown above. This prefix cannot be changed. Enter a unique suffix in the database name field and click Save to create the database.

Managing your MySQL Databases

Once you have your database created, you can manage it via PHPMyAdmin. To open the admin tool, click the “Manage Databases” tab

MySQL Admin Link

Click “MySQL Administration Tool” to launch PHPMyAdmin.

You will be prompted for a username & password, enter the database administrator name and the password. The user name does NOT have @yourdomain.com on the end, like your email addresses & FTP usernames & passwords do.

Once logged into PHPMyAdmin, you can administer your databases via SQL or the PHPMyAdmin interface.

PHPMyAdmin

Complete documentation on MySQL can be found at http://dev.mysql.com/doc/refman/5.0/en/index.html.

Connecting to MySQL via PHP

In order to access your database via PHP, you must use the server “localhost” – the following PHP code will establish the database connection:.

define ('DB_USER', 'UserName');
define ('DB_PASS', 'Password');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'DatabaseName');
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASS) OR die('Could not connect to MySQL: ' . mysql_error() );
@mysql_select_db (DB_NAME) OR die('Could not select database: ' . mysql_error() );
Replace UserName, Password, and DatabaseName with the appropriate values.

 
hosting/mysql.txt · Last modified: 2014/12/29 22:58 (external edit)