Configuring MySQL and MariaDB
Esta página aún no está disponible en tu idioma.
Preliminaries
Section titled “Preliminaries”Check if your MySQL installation has the InnoDB engine enabled:
$ mysql -h localhost -u root -p> show engines;In case of another default engine, there are two options:
- Use the org.hibernate.dialect.MySQL5InnoDBDialect dialect and avoid changing the default MySQL Storage Engine.
- Change the default engine
Change the default engine
Section titled “Change the default engine”Modify the MySQL configuration file named my.cnf
and under [mysqld] add
default-storage-engine = innodb
Change default charset
Section titled “Change default charset”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
character-set-server = utf8collation-server = utf8_general_ci/etc/mysql/mariadb.conf.d/50-client.cnf
default-character-set = utf8/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
default-character-set = utf8Once modified, a database server restart is needed.
Database creation
Section titled “Database creation”Create a database and user
Section titled “Create a database and user”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:
$ mysqlshow -h localhost -u root -p --status okmdb;More information at MySQL: Case Sensitivity in String Searches
Configure your OpenKM.cfg
Section titled “Configure your OpenKM.cfg”Edit the file $TOMCAT_HOME/OpenKM.cfg to
hibernate.dialect=org.hibernate.dialect.MySQL5Dialecthibernate.hbm2ddl=createor (recommended)
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialecthibernate.hbm2ddl=createMySQL timezone
Section titled “MySQL timezone”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:
SELECT * FROM mysql.time_zone_nameSo, for example, you could configure your jdbc connection like this if your system timezone is for example UTC+1:
spring.datasource.url=jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=Europe/MadridWhere Europe/Madrid is a valid value taken from the table time_zone_name.
Configure Tomcat datasources
Section titled “Configure Tomcat datasources”Edit the file $TOMCAT_HOME/conf/server.xml and enable the resource named jdbc/OpenKMDS
MySQL:
Section titled “MySQL:”<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&useUnicode=true&characterEncoding=UTF8"/>MariaDB:
Section titled “MariaDB:”<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&autoReconnect=true&useUnicode=true&characterEncoding=UTF8"/>Configure application login
Section titled “Configure application login”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>Check for JDBC Driver
Section titled “Check for JDBC Driver”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.
Run application
Section titled “Run application”As a process in the OpenKM startup, the application will automatically create an empty database structure.
Additional information
Section titled “Additional information”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:
c:\> mysqld --remove MySQL57or
c:\> sc delete MySQL57Create the service:
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"Migrate from Windows to Linux
Section titled “Migrate from Windows to Linux”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';