Liferay database configuration

By default, Liferay use hsql (hypersonic) database which is not recommanded to go with in production environment. Liferay provides a very easy way to use another SGBD on your portal by simple configuration. In this tutorial, we will see how to switch up to one of the following SGBD:

In brief:

In general, the changeover to the new SGBD is following these next steps:

Downloading the appropriate JDBC driver and putting it under the library folder of your server

Creating a blank database encoded for character set UTF-8

Setting up the connection information in the portal-ext.properties file by filling the following properties

1

2

3

4

jdbc.default.driverClassName=The jdbc driver class name

jdbc.default.url=The url to your database

jdbc.default.username=The database login

jdbc.default.password=The database password

Prerequisites:

In this tutorial, we will use Tomcat as server. We will refer to the tomcat server location as $TOMCAT_HOME. If you are using another server, $TOMCAT_HOME will corresponds to the folder where your server’s library folder is located.

The portal-ext.properties file where we will set up the connection information is located in the same folder as your $TOMCAT_HOME. If it doesn’t exist, create it.

If you go back to your database, you will see that it’s now populated by about 180 data tables that Liferay created on startup.

If you already configured your portal with hsql and want to re-configured it with the MySQL Database and add samples data, open portal-setup-wizard.properties file located in the same folder as portal-ext.properties. Set the setup.wizard.enabled to true and restart your server.

2- PostgreSQL

In this part, we will see how to use Liferay with PostgreSQL database.

Downloading the jdbc Driver

Same as MySQL. Liferay provides automatically the postgreSQL driver jar. So there is no need to download it.

Creating the blank database

Create a blank database and give it a name. Let’s consider that the created database is “lportal”.

Updating portal-ext.properties

Open your portal-ext.properties file and past the following lines :

1

2

3

4

5

# PostgreSQL

jdbc.default.driverClassName=org.postgresql.Driver

jdbc.default.url=jdbc:postgresql://localhost:5432/lportal

jdbc.default.username=postgres

jdbc.default.password=postgres

Check the configuration

You can verify that Liferay started with the correct dialect (PostgreSQL) by looking for the following line in your server log console/file: