Permissions errors when trying to install mariadb using mariadb-install-db

I have kubuntu 26.04 and I’m trying to install 3 instances of mariadb using mariadb-install-db. I went through several tutorials, which are all slightly different:

I don’t want to install these instances on my main partition, as the file size could be hundreds of GB and my main drive/partition isn’t big enough. I have a 2TB drive/partition I want to put them on. These tutorials mostly recommend putting the instances in /var/run on the main partition, so I’m not sure if that could be part of the problem.

I created 2 folders on the 2TB drive:

/media/Crucial2TB/mariadb1/
/media/Crucial2TB/mariadb2/

I set both to 755 permissions and the owner and group to “mysql”

When I get to the step where I install/initialize the mariadb folders using mariadb-install-db I keep getting these permissions errors:

raphael@server1:/media/Crucial2TB/mariadb1$ sudo /usr/bin/mariadb-install-db --defaults-file=/etc/mysql/my_multi.cnf --datadir=/media/Crucial2TB/mariadb1/ --verbose --user=mysql
Installing MariaDB/MySQL system tables in '/media/Crucial2TB/mariadb1/' ...
2026-10-01 12:59:01 0 [Warning] Can't create test file '/media/Crucial2TB/mariadb1/linuxserver.lower-test' (Errcode: 13 "Permission denied")
/usr/sbin/mariadbd: Cannot change uid/gid (errno: 1)
2026-10-01 12:59:01 0 [ERROR] Aborting

Installation of system tables failed!  Examine the logs in
/media/Crucial2TB/mariadb1/ for more information.

The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:

    shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf

You can also try to start the mariadbd daemon with:

    shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &

and use the command line tool /usr/bin/mariadb
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mariadb -u root mysql
    MariaDB> show tables;

Try '/usr/sbin/mariadbd --help' if you have problems with paths.  Using
--general-log gives you a log in /media/Crucial2TB/mariadb1/ that may be helpful.

The latest information about mariadb-install-db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the MariaDB discuss email list at https://lists.mariadb.org/postorius/lists/discuss.lists.mariadb.org/

Please check all of the above before submitting a bug report
at https://mariadb.org/jira

It says

Examine the logs in /media/Crucial2TB/mariadb1/ for more information.

but there are no files in that folder.

This is the config file in /etc/mysql/my_multi.cnf (that I basically copied & pasted from the mariadb website mariadbd-multi | Server | MariaDB Documentation):

[mysqld]
# This file should probably be in your home dir (~/.my.cnf)
       # or /etc/my.cnf
       # Version 2.1 by Jani Tolonen
       [mariadbd-multi]
       mariadbd   = /usr/bin/mariadbd-safe
       mysqladmin = /usr/bin/mysqladmin
       user       = multi_admin
       password   = multipass
       [mariadbd1]
       socket     = /tmp/mysql.sock1
       port       = 3306
       pid-file   = /media/Crucial2TB/mariadb1/server1.pid1
       datadir    = /media/Crucial2TB/mariadb1
       language   = /usr/local/share/mysql/english
       user       = raphael
       tmpdir     = /tmp
       [mariadbd2]
       socket     = /tmp/mysql.sock2
       port       = 3307
       pid-file   = /media/Crucial2TB/mariadb2/server1.pid2
       datadir    = /media/Crucial2TB/mariadb2
       language   = /usr/local/share/mysql/english
       user       = raphael

There are a lot of moving parts here and I don’t know where the issue is. Could it be the “–user” parameter? The user/group/permissions on the folders? The user in the my_multi.cnf file? The user I’m running as? Missing files? Something else?

I also tried editing the /etc/mysql/mariadb.conf.d/50-server-multi.cnf file as mentioned in Ubuntu 22.04 Multi Mariadb install - HackMD but I still got permissions errors.

I would have thought that running mariadb-install-db with sudo would have overridden any permissions issues, so the problem must be somewhere deeper in either Linux/Ubuntu or in the mariadb configs, but I don’t know where to look.

In fact, you have been misled. Actually, many codes of mariadbD-Multi of Maria DB point to mysql, so there will be problems when reading files. The simplest method is to manage each instance with an independent my.cnf

the giveaway is that sudo didn’t help. that usually means the block is below file permissions. check df -T on /media/Crucial2TB, if it is NTFS or exFAT then chown to mysql can never stick and a datadir there just won’t work, you’ll need ext4 or xfs. the other usual suspect on kubuntu is apparmor blocking mariadbd from writing outside /var/lib/mysql, so look for DENIED lines in dmesg after a failed run.

I think you found the issue! I found this in the dmesg:

[352503.220064] audit: type=1400 audit(1791221384.185:15149): apparmor="DENIED" operation="mknod" class="file" profile="mariadbd" name="/media/Crucial2TB/mariadb1/server1.lower-test" pid=646292 comm="mariadbd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
[352503.221799] audit: type=1400 audit(1791221384.187:15150): apparmor="DENIED" operation="capable" class="cap" profile="mariadbd" pid=646292 comm="mariadbd" capability=6  capname="setgid"

Now I need to investigate how to workaround that.

May be

vi /etc/apparmor.d/local/usr.sbin.mariadbd

/media/Crucial2TB/mariadb1/ r,
/media/Crucial2TB/mariadb1/** rwk,

apparmor_parser -r /etc/apparmor.d/usr.sbin.mariadbd

OR

sudo aa-complain /usr/sbin/mariadbd

kedar’s override should get you past the install step, but dont stop there. the running server hits the same profile when it writes pid files, sockets and everything under those datadirs, so make sure the local override covers all three instances plus the tmp and pid paths in your multi cnf, otherwise youll be chasing the same denial again at startup. flipping to complain mode first and watching dmesg as each instance starts is a nice way to catch any remaining paths before locking it down.