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 so 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 four 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 documentation 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 provided by Ubuntu and secure its installation.

At the time of writing, the following MariaDB Server versions will be installed, which may change when the corresponding package gets updated:

  • With Ubuntu 20.04: mariadb-server version 10.4.21

  • With Ubuntu 22.04, mariadb-server version 10.6.7

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 e.g. root.

sudo mysqladmin -u <admin_user> -p version

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

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

Server version          10.4.21-MariaDB-1:10.4.21+maria~bionic
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/run/mysqld/mysqld.sock
Uptime:                 59 min 51 sec

Threads: 16  Questions: 891020  Slow queries: 0  Opens: 119  Flush tables: 1  Open tables: 113  Queries per second avg: 248.125

Higher Stable Release

For information on how to install a higher stable release of MariaDB than the one provided by Ubuntu, refer to the MariaDB installation documentation.

The installation and use of MariaDB 10.6 is only supported and functional with ownCloud release 10.9 or above if it is a new ownCloud installation. Using an existing older version of ownCloud is not supported with MariaDB 10.6. The necessary manual migration steps are only available with ownCloud release 10.9 or above.

Upgrading an Existing Release

When upgrading from one minor version of MariaDB to another, e.g. from 10.4 to 10.5, follow the respective Upgrading MariaDB guide.

Do not upgrade a running ownCloud installation to MariaDB 10.6 until ownCloud release 10.9 or above is installed. ownCloud release 10.9 or above runs well with MariaDB lower than 10.6 and has special instructions for upgrading to MariaDB 10.6.
You must not skip minor releases of MariaDB when upgrading like from 10.4 → 10.6, you have to upgrade to each minor version in between step by step.

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 running an older version of MariaDB and 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 log in, 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 user’s 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 its database 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

After the installation, you need to configure your web server to access phpmyadmin. This is a manual task, depending on what your setup looks like and is 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 php-pgsql

In order to allow ownCloud access to the database, create an ownlcoud user who owns the owncloud database. The user and the database name can be any name that fits your needs.

Create the owncloud PostgreSQL user account. Note that the default admin account post installing PostgreSQL is postgres. If you have created another postgres admin user and disabled the default one, use the new one instead.

sudo -u postgres -c "createuser -e -P owncloud"

Define a password for the owncloud user. Note to remember this password to access the database later on:

Enter new password:
Enter it again:

Create the owncloud database owned by the owncloud user:

sudo -u postgres -c "createdb -e -O owncloud owncloud"

Oracle 11g

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