I was knee-deep in optimising my home lab’s MariaDB instance, trying to reduce memory usage on my Unraid server. With ~20+ Docker containers running, I wanted to optimise it as much as possible. I knew exactly what settings I needed to tweak in the MariaDB config—buffer pool size, query cache, connection limits—but there was one problem: I had no idea which configuration file I actually needed to edit. Was it /etc/my.cnf? /etc/mysql/my.cnf? Something else entirely? And running MariaDB in a Docker container added another layer of confusion. That’s when I realised I needed to properly identify MariaDB configuration file locations before making any changes.
Making edits to the wrong config file (or worse, making changes that get overridden by another file) is a waste of time and can lead to unexpected behaviour including files that I end up editing was not even persistant, so wasted efforts. Whether you’re troubleshooting database issues, optimising performance, or just trying to understand your setup, knowing exactly which configuration files MariaDB is reading—and in what order—is essential. This guide shows you the exact commands to identify these paths and understand the hierarchy of settings.
Before you can identify your running configuration file, you need to find where your database binaries are installed:
which mysqld which mariadb
Common locations include /usr/sbin/mysqld or /usr/bin/mariadb.
Use the --verbose --help flags to see which config files MariaDB reads and in what order:
For mysqld:
/usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
For mariadb:
/usr/bin/mariadb --verbose --help | grep -A 1 "Default options"
Output of mariadb –verbose –help command displaying the order in which MariaDB reads configuration files including /etc/my.cnf, /etc/mysql/my.cnf, and ~/.my.cnf
Example output:
Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
MariaDB reads multiple configuration files in a specific order. When you identify your configuration file paths, you’ll see that settings in later files override earlier ones if there are conflicts.
Typical reading order:
/etc/my.cnf – System-wide configuration/etc/mysql/my.cnf – MariaDB-specific settings~/.my.cnf – User-specific configuration/usr/etc/my.cnf – Additional system configsTo see where specific settings come from, check if a config file exists:
ls -la /etc/my.cnf ls -la /etc/mysql/my.cnf ls -la ~/.my.cnf
View the contents:
cat /etc/mysql/my.cnf
Modern MariaDB installations often use modular configuration directories:
ls -la /etc/mysql/mariadb.conf.d/ ls -la /etc/mysql/conf.d/
These directories contain .cnf files that are included by the main configuration file.
For detailed information about which files MariaDB actually opens:
sudo strace -e open,openat mysql 2>&1 | grep my.cnf
This shows real-time file access attempts, revealing exactly which configuration files are being read.
As shown in the example output, mysqld and mariadb binaries may read config files in slightly different orders:
/etc/mysql/my.cnf → ~/.my.cnf → /usr/etc/my.cnf/etc/my.cnf → /etc/mysql/my.cnf → ~/.my.cnfAlways check both if you’re running MariaDB, as they may prioritise different configuration locations.
This isn’t the first time I’ve done troubleshooting of MySQL or MariaDB database issues. There was a point when I was running much of my infrastructure from a very low-powered VPS and I would regularly have OOM Memory Killer issues which I eventually fixed. I also learned how to automatically restart failed services using systemd to keep MariaDB running reliably. Knowing a few handy MySQL commands helps, and understanding how to create MySQL databases and import SQLdump files is equally important.
For the issue here, knowing how to identify MariaDB configuration file locations was essential for effective database administration. The commands above will help you quickly find which config files your system is using, understand how they’re prioritised, and troubleshoot any configuration issues. Whether you’re running mysqld or mariadb, these methods work reliably across different installations.