Configuring PostgreSQL

Database creation

Create a database and user

DROP DATABASE IF EXISTS okmdb;
CREATE USER openkm WITH PASSWORD '*secret*';
CREATE DATABASE okmdb WITH OWNER openkm ENCODING 'UTF8';

Or from the command line.

$ createuser --pwprompt openkm
$ createdb --owner=openkm --encoding=UTF8 okmdb

More info at:

Configure your openkm.properties

This configuration property should be set before creating the database. Once the database has been initialized, do not modify it because doing so can damage your installation.

If your OpenKM installation has already been configured with another database, you can't switch to another database by changing this property.

Edit the file $TOMCAT_HOME/openkm.properties.

The supported dialects are:

  • com.openkm.db.dialect.PostgreSQL94Dialect
  • com.openkm.db.dialect.PostgreSQL92Dialect
  • com.openkm.db.dialect.PostgreSQL9Dialect

hibernate.dialect=com.openkm.db.dialect.PostgreSQL92Dialect
hibernate.hbm2ddl=create-only

Configure Tomcat datasources

Edit the file $TOMCAT_HOME/openkm.properties and enable the resource named jdbc/OpenKMDS.

spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/okmdb
spring.datasource.username=openkm
spring.datasource.password=*secret*
spring.datasource.validationQuery=SELECT 1 

Configure the values of the following attributes:

  • Username.
  • Password.
  • URL (change to your host and port).

Configure application login

Edit the file $TOMCAT_HOME/openkm.properties.

authentication.openkm.database=true

Enable native configuration parameter

Go to Administration > Configuration parameters.

native.sql.lowercase=true

Run application

During OpenKM startup, the application will automatically create an empty database structure.

Once the tables are created, OpenKM will automatically change the hibernate.hbm2ddl property from create-only to none.

Additional information

If you want to obtain the maximum performance from PostgreSQL, pgFouine will help you with this task.

PostgreSQL 9.6 and above

PostgreSQL versions 9.6 and above have changed some tables and columns in the schema. Check that you are using the correct JDBC driver.