Change ownCloud database from default SQLite to MariaDB etc. (CentOS7)

2 minute read

background

  • Due to circumstances, ownCloud, which was operated on CentOS 7, was reinstalled. (The version of the conventional ownCloud server is 8 series)
  • I have made the database the default SQLite, so I want to change it to MariaDB (ownCloud also recommends it).
  • MariaDB has a database that was used in ownCloud, which was used in the past, so you can overwrite it and use it.
  • You should be able to convert with MySQL basically the same work.

Method

  • The official documentation ** Converting Database Type ** describes how to use the ʻocc` command.
  • Use the db command of ʻocc`. The database conversion function is displayed as an experimental implementation as of October 07, 2020. (In my environment, I synced about 300 GB mainly for small document files that are not videos, but I was able to convert without problems)
  • When searching on the net, most of the things that get caught in Japanese are to delete config.php and reconfigure it from the web. I haven’t tried this one, so I haven’t verified which one is certain.

procedure

  • Proceed according to the above official document.

Update ownCloud config file

  • Add the following line to ownCloud configuration file {installation destination} /config/config.php

cinfig.php


'mysql.utf8mb4' => true,

MariaDB configuration update and restart

MariaDB update

# rpm -qa | grep -i mariadb
mariadb-5.5.50-1.el7_2.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-server-5.5.50-1.el7_2.x86_64
mariadb-libs-5.5.50-1.el7_2.x86_64
mariadb-5.5.56-2.el7.x86_64
# systemctl stop mariadb
# sudo yum update mariadb-server -y
# rpm -qa | grep -i mariadb
MariaDB-common-10.5.5-1.el7.centos.x86_64
MariaDB-server-10.5.5-1.el7.centos.x86_64
MariaDB-client-10.5.5-1.el7.centos.x86_64
MariaDB-compat-10.5.5-1.el7.centos.x86_64
# systemctl start mariadb
# ss -ltn | grep 3306
LISTEN     0      80          :::3306

MariaDB configuration update

  • Back up the configuration file
# cp -p /etc/my.cnf /etc/my.cnf.bak
  • Add settings to the [mysqld] block of the configuration file /etc/my.cnf

/etc/my.cnf


[mysqld]
   :
Omitted Conventional settings
   :
key_buffer_size         = 32M
table_cache             = 400
query_cache_size        = 128M
#in InnoDB:
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=1
innodb_log_file_size=256M
innodb_log_buffer_size = 128M
innodb_buffer_pool_size=2048M
innodb_buffer_pool_instances=3
innodb_read_io_threads=4
innodb_write_io_threads=4
innodb_io_capacity = 500
innodb_thread_concurrency=2
innodb_file_format=Barracuda
innodb_file_per_table=ON
innodb_large_prefix = 1
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci

MariaDB restart

# systemctl start mariadb
# systemctl status mariadb
● mariadb.service - MariaDB 10.5.5 database server
   :
   :
Omission

Convert database with occ command

# cd /var/www/html/owncloud
# sudo -u apache php occ db:convert-type --clear-schema --all-apps mysql owncloud 127.0.0.1 owncloud
  • The --clear-schema option overwrites the current schema
  • At the time of writing this article (October 07, 2020), the database conversion feature appears to be experimental (This feature is currently experimental.). Be prepared to use it.
This feature is currently experimental.
Enter a password to access a target database: 
Clearing schema in new database
Creating schema in new database
oc_account_terms
    0 [>---------------------------]
   :
   :
Omission
   :
   :
oc_vcategory_to_object
    0 [>---------------------------]

** It’s over **