Welcome to the second article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills.
In this post I will show you how to configure Liferay to use MySQL instead of Hypersonic. I assume you have followed all the steps in the previous post or that you are using a JNDI datasource. I also assume that you have installed MySQL on your system already. If not, please install it first. If the portal is still running stop it first before continuing with the next steps.
Installing the MySQL Connector
The first step is to install the MySQL Java connector so that JBoss and Liferay know how to connect to the database. You can download the connector from the official MySQL website.Copy the JAR file of the connector to the ‘%JBOSS_HOME%\server\default\lib\’ folder.
Create the Database
Use the MySQL command line to create a new database. In this post we will use ‘lportal’ as the name of the database. Use the following command to create the database:
create database lportal default character set utf8
Modify the configuration
Modify the ‘%JBOSS_HOME%\server\default\deploy\liferay-ds.xml’ file and set its content to:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>jdbc/LiferayPool</jndi-name> <connection-url>jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>username</user-name> <password>password</password> <min-pool-size>0</min-pool-size> </local-tx-datasource> </datasources>
Make sure you set the proper username and password.
Now fire up the portal and it will create the database schema for you. It fills the database with minimal data. You can use email@example.com and test to log in. That is it!