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 the case of another default engine, there are two options:
- Use the com.openkm.db.dialect.MySQL5InnoDBDialect dialect and avoid changing the default MySQL Storage Engine.
- Change the default engine
Change default engine
Section titled “Change 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. 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, the database server needs to be restarted.
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 the following command:
$ MySQL show -h localhost -u root -p --status okmdb;More information at MySQL: Case Sensitivity in String Searches
Configure your openkm.properties
Section titled “Configure your openkm.properties”Edit the file $TOMCAT_HOME/openkm.properties
spring.jpa.hibernate.ddl-auto=create-onlyspring.jpa.properties.hibernate.dialect=com.openkm.db.dialect.MySQL5InnoDBDialectMySQL Timezone
Section titled “MySQL Timezone”If you want to set your timezone in your JDBC connection according to the timezone configured in your system, you can first see the mappings for both MySQL and MariaDB like this:
SELECT * FROM MySQL.time_zone_nameSo, for example, you could configure your JDBC connection like this if your system timezone is UTC+1:
spring.data source.url=jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&nullNamePatternMatchesAll=true&serverTimezone=Europe/MadridWhere Europe/Madrid is a valid value taken from the table time_zone_name.
Configure Tomcat data sources
Section titled “Configure Tomcat data sources”Edit the file $TOMCAT_HOME/openkm.properties and enable the resource named JDBC/OpenKMDS
MySQL:
Section titled “MySQL:”spring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&nullNamePatternMatchesAll=true&serverTimezone=Europe/Madridspring.datasource.username=openkmspring.datasource.password=*secret*MariaDB:
Section titled “MariaDB:”spring.datasource.driver-class-name=org.mariadb.jdbc.Driverspring.datasource.url=jdbc:mariadb://localhost:3306/okmdb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&nullNamePatternMatchesAll=true&serverTimezone=Europe/Madridspring.datasource.username=openkmspring.datasource.password=*secret*Configure application login
Section titled “Configure application login”Edit the file $TOMCAT_HOME/openkm.properties
authentication.openkm.database=trueRun application
Section titled “Run application”During 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 the MySQL Windows service, you can remove it with one of these command lines:
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 names to uppercase. The following script will help with it:
select concat('rename table ', table_name, ' to ' , upper(table_name) , ';') from information_schema.tables where table_schema = 'okmdb';