Skip to content
Other versions

Loading…

Configuring MySQL and MariaDB

Check if your MySQL installation has the InnoDB engine enabled:

Terminal window
$ mysql -h localhost -u root -p
> show engines;

In case of another default engine, there are two options:

  1. Use the org.hibernate.dialect.MySQL5InnoDBDialect dialect and avoid changing the default MySQL Storage Engine.
  2. Change the default engine

Modify the MySQL configuration file named my.cnf

and under [mysqld] add

default-storage-engine = innodb

In Ubuntu 16.04 the default charset configured in MariaDB and MySQL is utf8mb4 but we recommend switching to utf8. In order to get the recommended charset you have to modify these files:

/etc/mysql/mariadb.conf.d/50-server.cnf

Terminal window
character-set-server = utf8
collation-server = utf8_general_ci

/etc/mysql/mariadb.conf.d/50-client.cnf

Terminal window
default-character-set = utf8

/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf

Terminal window
default-character-set = utf8

Once modified, a database server restart is needed.

DROP DATABASE IF EXISTS okmdb;
CREATE DATABASE okmdb DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
CREATE USER openkm@localhost IDENTIFIED BY '*secret*';
GRANT ALL ON okmdb.* TO openkm@localhost WITH GRANT OPTION;

You can check the database engine with:

Terminal window
$ mysqlshow -h localhost -u root -p --status okmdb;

More information at MySQL: Case Sensitivity in String Searches

Edit the file $TOMCAT_HOME/OpenKM.cfg to

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl=create

or (recommended)

hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl=create

If you want to set your timezone in your jdbc connection according to your timezone configured in your system, first you can see the mappings both for MySQL and for MariaDB in this way:

Terminal window
SELECT * FROM mysql.time_zone_name

So, for example, you could configure your jdbc connection like this if your system timezone is for example UTC+1:

Terminal window
spring.datasource.url=jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=Europe/Madrid

Where Europe/Madrid is a valid value taken from the table time_zone_name.

Edit the file $TOMCAT_HOME/conf/server.xml and enable the resource named jdbc/OpenKMDS

<Resource name="jdbc/OpenKMDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" validationQuery="select 1"
username="openkm" password="*secret*" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8"/>
<Resource name="jdbc/OpenKMDS" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000" validationQuery="select 1"
username="openkm" password="*secret*" driverClassName="org.mariadb.jdbc.Driver"
url="jdbc:mariadb://localhost:3306/okmdb?useSSL=false&amp;autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8"/>

Edity the file $TOMCAT_HOME/OpenKM.xml

<security:authentication-manager alias="authenticationManager">
<security:authentication-provider>
<security:password-encoder hash="md5"/>
<security:jdbc-user-service
data-source-ref="dataSource"
users-by-username-query="select usr_id, usr_password, 1 from OKM_USER where usr_id=? and usr_active='T'"
authorities-by-username-query="select ur_user, ur_role from OKM_USER_ROLE where ur_user=?"/>
</security:authentication-provider>
</security:authentication-manager>

Go to $TOMCAT_HOME/lib and check for the JDBC mysql-connector-java-5.1.12-bin.jar Driver.

If it is not present, download MySQL JDBC driver from MySQL Home Page and add it.

As a process in the OpenKM startup, the application will automatically create an empty database structure. 

Remove and create MySQL service in Windows

Section titled “Remove and create MySQL service in Windows”

If you have MySQL Window service you can remove it with one of these command line:

Terminal window
c:\> mysqld --remove MySQL57

or

Terminal window
c:\> sc delete MySQL57

Create the service:

Terminal window
c:\> "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe" --install MYSQL57 --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini"

When you migrate from Windows to Linux you must convert lowercase table name to uppercase. The next script will help on it:

select concat('rename table ', table_name, ' to ' , upper(table_name) , ';') from information_schema.tables where table_schema = 'okmdb';