Change MariaDB data directory

Hi there!
As I’ve installed Nextcloud on a single-board computer booting from a SD card, I want MariaDB to store its data on the external HDD to prevent the SD card from too many write operations.

I found the following tutorial:, but it seems like the config file layout changed since it was created.

On my machine, in the my.cnf file, there are only the following includings:


# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

When making the changes to the files in that directories, MariaDB claims to have set the new datadir, but when trying to leave the Nextcloud maintenance mode, many database-related errors are print out and Nextcloud stays in maintenance mode…

Does anyone know which files have to be changed in which way to store the database on the HDD?

which changes did you made?

you may post some. maybe that will help answer your question. :wink:

I changed the datadir and socket path in


and modified the socket path in

/etc/mysql/mariadb.conf.d/50-client.cnf and

The errors just claimed that it could not modify the value for the maintenance mode in the database. I reverted my changes already, so I can’t easily post that errors…:see_no_evil: