- Install mysql server:
- # emerge -pv dev-db/mysql
- # USE=-berkdb emerge -v dev-db/mysql
(Berkeley DB is deprecated in msyql, so no need to install it)
- At the end of above command, it suggested to run the following:
# emerge --config =dev-db/mysql-5.0.54
(This command will setup the mysql root pwd)
- # rc-update add mysql default
- # /etc/init.d/mysql start
- Install MySQL JDBC connector:
- Install the package
# emerge -pv dev-java/jdbc-mysql
I had jdk-1.6 installed earlier. Now the jdbc-mysql depends on jdk-1.5. So I have two jdk versions in this systems now.
- Copy the JDBC driver to glassfish domains/<liferay_domain>/lib subdir:
% cd domains/domain1/lib
% ln -s /usr/share/jdbc-mysql/lib/jdbc-mysql.jar
- Create the database:
# mysql -u root -p <<< "create database lportal;"
- Download the mysql script from Liferay Additional Files, and run
# mysql -u root -p < create-mysql.sql
- Create a separate liferay mysql user:
# mysql -u root -p
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON lportal.*
-> TO newuser'@'localhost' IDENTIFIED BY 'password';
- Restart glassfish:
- % bin/asadmin stop-domain
- % bin/asadmin start-domain
- Open localhost:4848 to enter glassfish admin console.
The default username is admin and the password is adminadmin.
- In the Glassfish admin console, go to Resources/JDBC/Connection Pools and create a connection pool to connect to the lportal database.

Click "Next" to continue:
In the next window, in the section of "Additional Properties", change the values in these fields:
- "URL" and "Url" fields. The format of these two fields are "jdbc:mysql://localhost:3306/databasename". If mysql is running in a different host, change the "localhost" to that hostname. "databasename" would be lportal in out case here.
- "User" field. Set the lportal mysql database username we created earlier.
- "Password" fields. Set the lportal mysql database user's password.
- In the Glassfish admin console, go to Resources/JDBC/JDBC Resources, create a JDBC resource with the name jdbc/LiferayPool, and associate it with the connection pool created in the previous step. If the LiferayPool exists already, edit it.
- Now we can restart the Glassfish.
In my case, at first, the Liferay - Glassfish didn't start. I checked glassfish domains/<liferay domain>/logs/server.log, saw that it complained about not being able to access mysql. Then open glassfish domains<liferay domain>/config/domain.xml, and found out password was entered wrong. Fixed the password and Glassfish started fine!
References: