Manual Installation Databases

Introduction

This document gives you an overview of databases supported by ownCloud. It describes some basic installation steps and how to create an administrative user for the database. This administrative user is necessary that the ownCloud database and user who further manages the ownCloud database can be created The ownCloud database user has no access to other databases!

Possible Databases

When installing ownCloud Server & ownCloud Enterprise editions the administrator may choose one of 4 supported database products. These are:

  • SQLite

  • MYSQL/MariaDB (recommended)

  • PostgreSQL

  • Oracle 11g (Enterprise-edition only)

After selecting and installing a database as described below, read the Database Configuration on Linux documenation for more information regarding database engine configuration.

SQLite

SQLite is not supported by the ownCloud Enterprise edition.
SQLite should only be used for testing and lightweight single user setups.

SQLite has no client synchronization support, so other devices will not be able to synchronize with the data stored in an ownCloud SQLite database.

SQLite will be installed by ownCloud when installed via package manager. The necessary dependencies will be satisfied. If you used the package manager to install ownCloud, you may "Finish Setup" with no additional steps to configure ownCloud using the SQLite database for limited use.

MYSQL/MariaDB

MariaDB is the ownCloud recommended database. It may be used with either ownCloud Server or ownCloud Enterprise editions. Please look for additional configuration parameters in the Database Configuration on Linux guides.

Standard Installation

Use these commands to install MariaDB and secure it´s installation:

sudo apt install mariadb-server
sudo mysql_secure_installation

Check access and the version of MariaDB, replace <admin_user> as either defined during mysql_secure_installation above or use eg. root.

sudo mysqladmin -u <admin_user> -p version

If you get an output like the below, your database is up and running and ready to serve requests.

mysqladmin  Ver 9.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version          10.3.25-MariaDB-0ubuntu0.20.04.1
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 14 min 53 sec

Threads: 7  Questions: 470  Slow queries: 0  Opens: 177  Flush tables: 1  Open tables: 31  Queries per second avg: 0.526

Latest Stable Release

For how to install the latest stable release of MariaDB, please refer to the MariaDB installation documentation.

If you have an existing installation of MariaDB and upgrade to a higher version, do not forget to run the following command, to handle the new setup for admin users — especially when upgrading to MariaDB 10.4.3 upwards:

sudo mysql_upgrade

Notes For MariaDB Lower Than 10.4.3

For MariaDB server releases lower than 10.4.3, you will be prompted during the installation to create a root password. Be sure to remember your password, as you will need it during the ownCloud database setup.

To install an ownCloud database, you need an administrative user who can login, has rights to create/modify databases and users. If this user does not exist like on MariaDB server releases higher than 10.4.3 or if you want to create a temporary user for this task, you manually have to create one. You will be asked for the mysql root users password:

sudo mysql --user=root -p

CREATE USER 'dbadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Notes For MariaDB Higher Than 10.4.3

From MariaDB 10.4.3 onwards, the authentication method has changed to UNIX sockets. For details, please refer to: MariaDB: Authentication Plugin - Unix Socket. The unix_socket authentication plugin allows the user to use operating system credentials when connecting to MariaDB via a local UNIX socket. Follow the procedure below to create an admin user for non-socket login, giving ownCloud access to create it’s database respectively for phpMyAdmin. This is not the ownCloud user! Don’t forget to change the username and password according to your needs.

sudo mysql
MariaDB [(none)]>
 CREATE USER IF NOT EXISTS 'dbadmin'@'localhost' IDENTIFIED BY 'password';
 GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' WITH GRANT OPTION;
 FLUSH PRIVILEGES;
 SHOW GRANTS FOR 'dbadmin'@'localhost';

phpmyadmin

If you want to install phpMyAdmin as a graphical interface for administering the database, run the following command:

sudo apt install phpmyadmin

Post installing, you need to configure your Web Server to access phpmyadmin. This is a manual task, dependent how your setup looks like and not part of this documentation.

You can run sudo dpkg-reconfigure phpmyadmin to reconfigure phpmyadmin.

PostgreSQL

To install postgres, use the following command (or that of your preferred package manager):

sudo apt-get install postgresql

In order to allow ownCloud access to the database, create a known password for the default user, postgres, which was added when the database was installed.

sudo -i -u postgres psql
postgres=# \password
Enter new password:
Enter it again:
postgres=# \q
exit

Oracle 11g

Oracle 11g is only supported for the ownCloud Enterprise edition. Please see the Oracle Database Setup & Configuration in the Enterprise documentation section.