As discussed above Nextcloud is using the TRANSACTION_READ_COMMITTED transaction isolation
level. Some database configurations are enforcing other transaction isolation levels. To avoid
data loss under high load scenarios (e.g. by using the sync client with many clients/users and
many parallel operations) you need to configure the transaction isolation level accordingly.
Please refer to the MySQL manual
for detailed information.

For setting up Nextcloud to use any database, use the instructions in Installation wizard. You should not have to edit the respective values in the config/config.php. However, in special cases (for example, if you want to connect your Nextcloud instance to a database created by a previous installation of Nextcloud), some modification might be required.

An Nextcloud instance configured with MySQL would contain the hostname on which
the database is running, a valid username and password to access it, and the
name of the database. The config/config.php as created by the
Installation wizard would therefore contain entries like
this:

The default configuration for PostgreSQL (at least in Ubuntu 14.04) is to use the peer authentication method. Check /etc/postgresql/9.3/main/pg_hba.conf to find out which authentication method is used in your setup.
To start the postgres command line mode use:

sudo-upostgrespsql-dtemplate1

Then a template1=# prompt will appear. Now enter the following lines and confirm them with the enter key:

CREATEUSERusernameCREATEDB;CREATEDATABASEnextcloudOWNERusername;

You can quit the prompt by entering:

\q

A Nextcloud instance configured with PostgreSQL would contain the path to the socket on
which the database is running as the hostname, the system username the PHP process is using,
and an empty password to access it, and the name of the database. The config/config.php as
created by the Installation wizard would therefore contain entries like
this:

The host actually points to the socket that is used to connect to the database. Using localhost here will not work if postgreSQL is configured to use peer authentication. Also note that no password is specified, because this authentication method doesn’t use a password.

If you use another authentication method (not peer), you’ll need to use the following steps to get the database setup:
Now you need to create a database user and the database itself by using the
PostgreSQL command line interface. The database tables will be created by
Nextcloud when you login for the first time.

To start the postgres command line mode use:

psql-hlocalhost-Upostgres

Then a postgres=# prompt will appear. Now enter the following lines and confirm them with the enter key:

A Nextcloud instance configured with PostgreSQL would contain the hostname on
which the database is running, a valid username and password to access it, and
the name of the database. The config/config.php as created by the
Installation wizard would therefore contain entries like
this:

The database request takes too long and therefore the MySQL server times out. It’s
also possible that the server is dropping a packet that is too large. Please
refer to the manual of your database for how to raise the configuration options
wait_timeout and/or max_allowed_packet.

Some shared hosters are not allowing the access to these config options. For such
systems Nextcloud is providing a dbdriveroptions configuration option within your
config/config.php where you can pass such options to the database driver.
Please refer to Configuration Parameters for an example.