How to Use MySQL Print

  • 153


MySQL is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server.

Path to MySQL:

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.

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;

2. 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 succesfully. The database must be a valid one that you have created through the MyAdmin interface. The username must be one created in MyAdmin with adequate permissions to the specified database.


3. 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 convienent 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.

1. 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.


2. 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.


3. 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.

Connecting to MySQL with JSP

If you are using MySQL with JSP, ie. our Tomcat based Java web hosting, you will need the Class.forName path to the MySQL Driver:


To test your connection:

java.sql.Connection conn;
conn = DriverManager.getConnection(


It is a web-based program that allows you to work with the MySQL database with out having to use or know unix command line. You can add and delete databases, tables and data contained in those tables.

Currently phpMyAdmin can:

  • create and drop databases
  • create, copy, drop and alter tables
  • delete, edit and add fields
  • execute any SQL-statement, even batch-queries
  • manage keys on fields
  • load text files into tables
  • create (*) and read dumps of tables
  • export (*) and import data to CSV values
  • administer multiple servers and single databases
  • communicate in more than 20 different languages

To access MySQL with phpMyAdmin click on Services in the left pane, then the pencil for MySQL service. Then you will have a link "MySQL Administration Tool" clicking on that brings up a new window to allow you to log into your database where you can setup tables using a web browser.

Was this answer helpful?

« Back