« OpenID Authentificat... | Main | RichFaces - How to... »

Ubuntu - MySQL - Glassfish

To install MySQL on Ubuntu to be used in a Glassfish JEE App is very easy. 

You can download and install MySQL Server using the Synaptic Tool in Ubuntu. During Setup you will be asked for a root password. this is a password for the user "root" inside the mySQL Server. So its not your Linux root password.

After intalling mysql server you can easily start and stop it with

 > sudo /etc/init.d/mysql start

 > sudo /etc/init.d/mysql stop

To get into the mysql console use

 >mysql -u root -p

There you will be ask for the mysql root password.

To create a new database use the following command form the mysql console:

mysql> create database my_database;

Now you can setup the JDBC Pool inside Glassfish server.

First download the JDBC Driver form mysql download page and put the 'mysql-connecto-java-5.1.x.jar' into glassfish/domains/domain1/lib/ext

use the following Class Name to configure you JDBC Pool:  com.mysql.jdbc.jdbc2.optional.MysqlDataSource

Use the additional params:

  • databaseName : [you_database_name]
  • user: root
  • password : [you mysql admin password]