Using
mySQL
Overview of MySQL database.
The MySQL database server is a very robust, SQL based platform that is
provided for use with the standard or higher plans. It is often utilized as a
data source for Web sites requiring dynamic content. The languages most often
used to interface with the database server are Perl and PHP, however, C, C++,
and Python among others may also be used. The official MySQL Web site is located
at: http://www.mysql.com/
Creating/Deleting/Editing Databases and Users
All administration of your MySQL databases and users can be done through our
convenient web based phpMyAdmin interface. This program is provided to all of
our Web hosting customers. It is available in your Control Panel (CP). For help
with this tool check out the phpMyAdmin
documentation.
Connecting to MySQL through Telnet
Use the following outline to connect and begin querying the MySQL server from
a Telnet session.
Remember that you can not connect to your databases remotely due to security
concerns, you can only connect from localhost.
-
Connect To The MySQL Server
bash$ mysql -u USERNAME -p
Enter Password: PASSWORD
-
Connect To The Database
bash$ use DATABASENAME;
-
Receving Help
bash$ help
Connecting to MySQL through Perl using the MySQLPerl
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.
-
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;
-
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.
The database must be a valid one that you have created through the
phpMyAdmin interface in the CP. The username must be one created in MyAdmin
with adequate permissions to the specified database.
Mysql->connect('localhost','DATABASENAME','USERNAME','USERPASSWORD');
-
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. Remember that you can use our convenient web based
MyAdmin interface to view or edit these settings.
Connecting to MySQL through 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.
-
Connect to the MySQL server
Use the following statement to connect to the database server. Substitute
the username, and
password for ones who have created in the MyAdmin interface and have given
adequate
permissions to this database.
MYSQL_CONNECT('localhost','USERNAME','PASSWORD');
-
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");
-
Executing A Query
You are now ready to execute your queries. Remember that the databases and
users used must be created in the MyAdmin interface in your CP. Most
problems that arise with your scripts will be due to incorrect permission
settings.
Restrictions and other information
The following restrictions are currently affective regarding all of our web
hosting accounts:
-
You cannot connect to any of your databases from remote hosts. This
limitation is due to security concerns. For now you may only connect from
localhost.
-
You may not utilize the data-infile data-outfile functions of the MySQL
server. This is due to security reasons.
The Official MySQL Documentation
The official MySQL documentation may be found at: http://www.mysql.com/
Other useful information about MySQL may be found at the following locations:
Backing up a MySQL Database
There are two main ways to back up or restore a MySQL database on our
servers: via SSH Telnet access or the phpMyAdmin interface.
If you need SSH Telnet access, just send us a ticket with your request to be
enabled for it, though we reserve the rights to accept or decline any request
for Telnet/SSH access. To access the phpMyAdmin interface, click on the "mySQL
Databases" link and then "phpMyAdmin" on your control panel.
How to back up a mySQL database using SSH Telnet:
Log into your account on our server and issue the following command:
[This is all one command line!]
/usr/bin/mysqldump $databasename
-u $user -p$password > /home/$user/file.dump
$ indicates a variable, so instead of entering $user, you'll enter your
actual user name for your account. Your mySQL username and password are usually
the same as the ones that you use to access your control panel.
For example, your actual command might look like this:
/usr/bin/mysqldump julie_com -u julie -p18circ >
/home/julie/backup.sql
How to restore a mySQL database using SSH Telnet:
Log into your account on our server and issue the following command:
[This is all one command line!]
mysql $databasename -u
$user -p$password < /home/$user/file.dump
How to back up a mySQL database using phpMyAdmin:
Click on your database name shown on the upper left.
Go to the section called "View dump (schema) of database" and
choose options for backing up structure only, structure and data, or adding drop
tables. To view what your backup file will look like, click on the
"Go" button. When you're ready to send your back up to a file, check
the send box and click "Go", then follow the prompts for how to name
the file and where to send it.
How to restore a mySQL database using phpMyAdmin:
Click on your database name shown on the upper left.
Locate your back up file for the database that you want to restore. Open it
and copy the entire contents.
Paste into the field called "Run SQL query/queries on database
yourdomain_com" and click the "Go" button.