MySQL Service
"July" "2011"

english Welcome to LSI.

1. Connection to MySQL ServiceL

This document will show you how to establish a connection with the MySQL server. It will also talk about how to access the service in two ways: in graphical mode using phpMyAdmin web environment, or in textual mode (by the command line interface). Finally, some examples about how to connect to the service from PHP and MySQL will be given.

1.1 Service access information

Server name:
Port: 3306

You can get a username and password by mail at or by web at

NOTE: Database name will be the same as your username.

1.2 Web access

With your username and password you will be able to access the service from the webpage provided by RDlab:

Note: Secure connection is also available through the URL:

Once in, the page will show a form where you will be asked for your MySQL username and password.

After the data is entered you will access the main page. This interface allows creating tables, deleting them, querying data and modifying information.

1.3 Text mode connection

In order to connect in textual mode (terminal or Command Line Interface) we can type this command while in a Unix system:

mysql -u <username> -p

The command line will answer “Enter password:”, where we should enter our password. Once authenticated, we will be able to execute any command we want by the command line interface.

By using the command “SHOW DATABASES;” we will see that a database named like our username is available. To select it, we will execute the following:

mysql>USE <username>;

1.4 Php connection example

If we want to establish connection from a PHP environment, we can do it by using the next code snippet:

$host = "";
$login_name = "<username>";
$password = "<password>";
$database = "<username>";
MySQL_connect("$host","$login_name","$password") or die("No em puc connectar a la BD");
MySQL_select_db("$database") or die("No puc sel·leccionar la BD");

1.5 Java connection example

n order to establish connection from a java project, it is necessary to download the mysql-connector-java-5.0.8-bin.jar library, add it to our project and import it with the following sentence:

import java.sql.*;

Once done, we should execute the next code inside a try-catch block:

String db_connect_string = “jdbc:mysql://<username>”;
String db_userid =“<username>”;
String db_password = “<password>”;
Connection conn = DriverManager.getConnection(db_connect_string, db_userid,db_password);

1.6 External links

  1. phpMyAdmin Documentation:
  2. MySQL Reference:
  3. MySQL des de Java: