2

I'd like to install mariadb on Debian 10 with the --basedir=/usr/local/mariadb and --datadir=/data/mariadb. I've tried to add these options to the apt install mariadb-server command line but I get error messages saying the options aren't recognized.

So what then is the correct way to install mariadb using non-default root and data directories?

1 Answer 1

1

Those are options for the mariadb program itself. You can put them in configuration files, overriding what is already set, e.g. on my system:

$ sudo ack datadir /etc/mysql/ /etc/mysql/mariadb.conf.d/50-server.cnf 21:datadir = /var/lib/mysql 

So I would suggest making your own custom config file in /etc/mysql/mariadb.conf.d/ numbered after 50 and override it there:

[mysqld] basedir = /usr/local/mariadb datadir = /data/mariadb 

Do bear in mind that the installation of the mariadb Debian package will create some databases in the default location first as part of its setup. You may want to pre-create your config files (which the install won't overwrite) so that it gets the correct settings at first startup and during the initial configuration.

Also mariadb doesn't currently have an AppArmor profile in Debian at the moment but it could grow one, so you'd have to watch out for that as it's very likely to restrict the daemon to only being able to access /var/lib/mysql.

1
  • This "pre-create your config files" tip here was key for me solving a similar problem. Commented Sep 12, 2023 at 20:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.