MySQL Database Instructions

MySQL Database Instructions

You can create various number of MySQL databases depending on your host using the “Add MySQL Database” function of your Control Panel. Please note that most web hosts do not provide any support related to the use of this complex application beyond the information provided on this page. For more information, please visit the MySQL Home Page.

At some providers your MySQL USERNAME is your domain name without the extension (e.g., if your domain name is fred.com, your MySQL USERNAME is: fred.) MySQL truncates usernames to 16 characters, so if your domain name is longer than 16 characters, just use the first 16 (e.g., the USERNAME for ihaveanincrediblylongdomainname.com would be: ihaveanincredibl.)

Your MySQL PASSWORD is the password you chose when you created your first database from your control panel. Any databases you create after the first one must use the same password.

Accessing MySQL through Telnet

Use the following outline to connect and begin querying the mySQL server from telnet. Remember that you cannot connect to your databases remotely due to security concerns, you can only connect from localhost.

    1. Connect to the mySQL Serverservername:> mysql -u USERNAME -pEnter Password: PASSWORD
    1. Connect to the Databasemysql> use DATABASENAME;
    1. Receiving Helpmysql> help

 

Accessing MySQL with the MySQL Perl Module

Use the following outline to connect and begin querying the mySQL server from a Perl script. Remember that you cannot connect to your databases remotely due to security concerns. You can only connect from localhost.

    1. Declarations: You must require the mySQL package for your script to function properly. Do this by including the following line in your code: use Mysql;
    1. Connect to the Database: Somewhere near the beginning of your script, you need to make your initial connection to the database server. Using the following form, substitute your database, username, and password for the examples to connect successfully.Mysql->connect('localhost','DATABASENAME','USERNAME','USERPASSWORD');
    1. Executing a Query: You are now ready to begin querying the database server. [Most problems that you may incur will generally occur due to invalid permission settings for the specified user.]

 

Accessing MySQL with PHP

Use the following outline to connect and begin querying the mySQL server from within your PHP scripts. Remember that you cannot connect to your databases remotely due to security reasons. You can only connect to them form localhost.

    1. Connect to the mySQL Server: Use the following statement to connect to the database server. Substitute the username, and password for ones you have created in the WebControl System.MYSQL_CONNECT('localhost','USERNAME','PASSWORD');
    1. Select Your Database: Use the following statement to select the database you wish to connect to. Make sure you substitute the example with your database name.@mysql_select_db("DATABASENAME");
    1. Executing A Query: You are now ready to execute your queries. (Most problems that arise with your scripts will be due to incorrect permission settings.)

 

Export (Dump) or Backup your MySQL Database

To create a backup (dump) of your MySQL database through shell: Connect via SSH, navigate to the directory in which you want your backup stored, and issue the following command:

mysqldump -uusername -ppassword dbname > file.txt

(where username is your MySQL username; password is your MySQL password; dbname is the name of your database; and file.txt is the name of your backup file.)

Import / Restore your MySQL Database

To import/restore your database from an existing backup: Connect via SSH, navigate to the directory that contains your backup, and issue the following command:

mysql -uusername -ppassword dbname < file.txt

(where username is your MySQL username; password is your MySQL password; dbname is the name of your database; and file.txt is the name of your backup file.)

ODBC & JDBC

At this time, we do not offer support for ODBC or JDBC.