Where Is the MariaDB Data Directory?
Default MariaDB datadir locations on Linux and Windows.
Last updated
MariaDB stores databases, tables, and logs under the datadir defined by the server config. The default differs between Linux packages and Windows installs.
Always confirm the live value because installers and admins often change it. Stop the server before moving the directory and update socket and config paths to match.
Where MariaDB stores this, by platform
/var/lib/mysql
Default datadir on most Linux packages. Config is commonly under /etc/mysql/mariadb.conf.d or /etc/my.cnf.d/mariadb-server.cnf with a datadir and socket entry. Verify with SELECT @@datadir or mysqld --verbose --help. Moving it requires copying with permissions preserved, updating datadir and socket in server and client config, and adjusting AppArmor or SELinux policy.
C:\Program Files\MariaDB [version]\data
Default DATADIR for Windows MSI installs, defined as INSTALLDIR\data where [version] is the installed release. my.ini is created in the data directory by mariadb-install-db.exe. Confirm with SELECT @@datadir. Uninstall may offer to remove the data directory, so back up before removing or upgrading.
Frequently asked questions
How do I find the real datadir if it was changed?
Run SELECT @@datadir; in the client or check datadir in my.cnf, my.ini, and included config directories. The install default is only a starting point.
Can I just copy /var/lib/mysql while the server runs?
No. Stop MariaDB first or take a consistent backup with mariabackup or mysqldump. A hot file copy of InnoDB files can produce an unusable copy.
Notice an outdated path? Let us know.