Learn how to configure MariaDB using option files (my.cnf/my.ini), including file locations, syntax, and command-line overrides.
You can configure MariaDB to run the way you want by configuring the server with MariaDB's option files. The default MariaDB option file is called my.cnf on Unix-like operating systems and my.ini on Windows. Depending on how you've installed MariaDB, the default option file may be in a number of places, or it may not exist at all.
The following options relate to how MariaDB handles option files. These options can be used with most of MariaDB's command-line tools, not just mariadbd. They must be given as the first argument on the command-line:
MariaDB reads option files from many different directories by default. See the sections below to find out which directories are checked for which system.
For an exact list of option files read on your system by a specific program, you can execute a command like this ($program stands for any MariaDB program, including the Server):
For example:
The option files are each scanned once, in the order given by --help --verbose. The effect of the configuration options is the same as if they would have been given as command-line options in the order they are found.
On Linux, Unix, or Mac OS X, the default option file is called my.cnf. MariaDB looks for the MariaDB option file in the locations and orders listed below.
The locations are dependent on whether the DEFAULT_SYSCONFDIR option was defined when MariaDB was built. This option is usually defined as /etc when building , but it is usually not defined when building or .
If the DEFAULT_SYSCONFDIR cmake option is undefined, MariaDB looks for the MariaDB option file in the following locations, and in the following order:
If the DEFAULT_SYSCONFDIR cmake option is defined, MariaDB looks for the MariaDB option file in the following locations in the following order:
MARIADB_HOME or MYSQL_HOME is the containing the path to the directory holding the server-specific my.cnf file. If MYSQL_HOME is not set, and the server is started with , MYSQL_HOME is set as follows:
If there is a my.cnf file in the MariaDB data directory, but not in the MariaDB base directory, MYSQL_HOME
Note that if MARIADB_HOME is set, MYSQL_HOME is not used, even if set.
On Windows, the option file can be called either my.ini or my.cnf. MariaDB looks for option files in the following locations, and in the following order:
The System Windows Directory is the directory returned by the function. The value is usually C:\Windows. To find its specific value on your system, open and execute:
The Windows Directory is the directory returned by the GetWindowsDirectory function. The value may be a private Windows Directory for the application, or it may be the same as the System Windows Directory returned by the GetSystemWindowsDirectory function.
INSTALLDIR is the parent directory of the directory where mysqld.exe is located. For example, if mysqld.exe
Note that if MARIADB_HOME is set, MYSQL_HOME is not used, even if set.
MariaDB looks in all of the above locations, in order, even if it has already found an option file, and it's possible for more than one option file to exist. For example, you could have an option file in /etc/my.cnf with global settings for all servers, and another option file in ~/.my.cnf (that is, your user account's home directory) which specifies additional settings (or override previously specified settings) that are specific only to that user.
Option files are usually optional. However, if the option is set, but the file does not exist, MariaDB raises an error. If the --defaults-file option is set, MariaDB only reads the option file referred to by this option.
If an option or system variable is not explicitly set, then it will be set to its default value. See for a full list of all server system variables and their default values.
If an option is set multiple times, the later setting will override the earlier setting.
If is set, there are various other log file naming options that, if set, should be placed later in the configuration file hierarchy. Later settings override earlier settings, so log-basename overrides any earlier log file name settings. See for details.
MariaDB can be configured to read options from custom options files with the following command-line arguments. These command-line arguments can be used with most of MariaDB's command-line tools, not just . They must be given as the first argument on the command line:
The syntax of MariaDB option files is as follows:
Lines starting with # are comments.
Empty lines are ignored.
Option groups use the syntax [group-name]. See the section below for more information on available option groups.
A MariaDB program can read options from one or many option groups. For an exact list of option groups read on your system by a specific program, you can execute ($program is a placeholder for any MariaDB program):
For example:
MariaDB programs reads server options from the following server option groups:
X.Y in the examples above refer to the base (major.minor) version of the server. For example, MariaDB 11.4 would read from [mariadb-11.4]. By using the mariadb-X.Y syntax, you can create option files that have MariaDB-only options in the MariaDB-specific option groups. That would allow the option file to work for both MariaDB and MySQL.
MariaDB programs reads client options from the following option groups:
Many MariaDB tools reads options from their own option groups as well:
MariaDB can be configured to read options from option groups with a custom suffix by providing the following command-line argument. This command-line argument can be used with most of MariaDB's command-line tools, not just . It must be given as the first argument on the command line:
The default group suffix can also be specified via the MYSQL_GROUP_SUFFIX .
Example: To create a custom prompt for the mariadb command-line client via a custom group, add this to the option file (for instance, /etc/my.cnf):
Then, launch mariadb like this:
It is possible to include additional option files from another option file. For example, to include /etc/mysql/dbserver1.cnf, an option file could contain:
It is also possible to include all option files in a directory from another option file. For example, to include all option files in /etc/my.cnf.d/, an option file could contain:
The option files within the directory are read in alphabetical order.
All option file names must end in .cnf on Unix-like operating systems. On Windows, all option file names must end in .cnf or .ini.
If a .cnf file cannot be read an executable (a MariaDB server or a client tool) will exit with an error. One can use ?includedir to skip unreadable files without failing out.
If a .cnf file cannot be read an executable (a MariaDB server or a client tool) will exit with an error.
You can check which options a given program is going to use by using the command-line argument:
This command-line argument can be used with most of MariaDB's command-line tools, not just . It must be given as the first argument on the command-line:
You can also check which options a given program is going to use by using the utility, and providing the names of the option groups that the program reads:
The my_print_defaults utility's --mariadbd command-line option provides a shortcut to refer to all of the :
MySQL supports an obfuscated authentication credential option file called .mylogin.cnf that is created with .
MariaDB does not support this. The passwords in MySQL's .mylogin.cnf are only obfuscated, rather than encrypted, so the feature does not really add much from a security perspective. It is more likely to give users a false sense of security, rather than to seriously protect them.
MariaDB supports certain prefixes that can be used with options. The supported option prefixes are:
For example:
Dashes (-) and underscores (_) in option names are interchangeable.
If an option is not explicitly set, then the server or client will simply use the default value for that option.
MariaDB Server options can be set in .
For a list of options that can be set for MariaDB Server, see the list of options available for .
Most of the can also be set in MariaDB's option file.
MariaDB client options can be set in .
See the specific page for each to determine what options are available for that program.
Most MariaDB installations include a sample MariaDB option file called my-default.cnf.
In source distributions, the sample option files are usually found in the support-files directory, and in other distributions, in the share/mysql directory that is relative to the MariaDB base installation directory.
You can copy one of these sample MariaDB option files and use it as the basis for building your server's primary MariaDB option file.
Minimal my.cnf file that you can use to test MariaDB:
The following is an extract of an option file that one can use if one wants to work with both MySQL and MariaDB.
This page is licensed: CC BY-SA / Gnu FDL
Else, MYSQL_HOME is set to the MariaDB base directory.
Server
installdir\my.cnf
Server
installdir\data\my.ini
Server
installdir\data\my.cnf
Server
%mariadb_home%\my.ini
Server (from MariaDB 10.6)
%mariadb_home%\my.cnf
Server (from MariaDB 10.6)
%mysql_home%\my.ini
Server
%mysql_home%\my.cnf
Server
defaults-extra-file
File specified with , if any
C:\Program Files\INSTALLDIRC:\Program Files\MARIADB_HOME or MYSQL_HOME is the environment variable containing the path to the directory holding the server-specific my.cnf file.
The !include directive can be used to include other option files. See the Including Option Files section below for more information on this syntax.
The !includedir directive can be used to include all .cnf files (and potentially .ini files) in a given directory. The option files within the directory are read in alphabetical order. See the Including Option File Directories section below for more information on this syntax.
The ?includedir (introduced in MariaDB 11.4.10 and 11.8.6) directive works like !includedir but skips unreadable files, instead of failing with an error.
Dashes (-) and underscores (_) in options are interchangeable.
Double quotes can be used to quote values
\n, \r, \t, \b, \s, \", \', and \\ are recognized as character escapes for new line, carriage return, tab, backspace, space, double quote, single quote, and backslash respectively.
Certain option prefixes are supported. See the Option Prefixes section below for information about available option prefixes.
See the Options section below for information about available options.
[mariadbd]
Options read by MariaDB Server.
[mariadbd-X.Y]
Options read by a specific version of MariaDB Server. For example, [mariadbd-11.4].
[galera]
Options read by MariaDB Server, but only if it is compiled with support. All builds on Linux are compiled with Galera Cluster support. When using one of these builds, options from this option group are read even if the Galera Cluster functionality is not enabled.
[mysql_upgrade]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-upgrade]
Options read by .
[sst]
Specific options read by the and the xtrabackup-v2 SST method.
[mysql]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-client]
Options read by .
[mysqldump]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-dump]
Options read by .
[mysqlimport]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-import]
Options read by .
[mysqlbinlog]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-binlog]
Options read by .
[mysqladmin]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-admin]
Options read by .
[mysqlshow]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-show]
Options read by . Note that this program reads [client] group options, too.
[mysqlcheck]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-check]
Options read by .
[mysqlslap]
Options read by , including both MariaDB Server and MySQL Server.
[mariadb-slap]
Options read by .
[odbc]
Options read by , but only if the parameter is set.
Read options from option files, print all option values, and then exit the program.
Don't read options from any option file.
--defaults-file =path
Only read options from the given option file.
--defaults-extra-file =path
Read this extra option file after all other option files are read.
--defaults-group-suffix =suffix
In addition to the default option groups, also read option groups with the given suffix.
/etc/my.cnf
Global
/etc/mysql/my.cnf
Global
$MARIADB_HOME/my.cnf
Server (from MariaDB 10.6)
$MYSQL_HOME/my.cnf
Server (before MariaDB 10.6)
defaults-extra-file
File specified with --defaults-extra-file, if any
~/.my.cnf
User
DEFAULT_SYSCONFDIR/my.cnf
Global
$MARIADB_HOME/my.cnf
Server (from MariaDB 10.6)
$MYSQL_HOME/my.cnf
Server (before MariaDB 10.6)
defaults-extra-file
File specified with --defaults-extra-file, if any
~/.my.cnf
User
System Windows Directory\my.ini
Global
System Windows Directory\my.cnf
Global
Windows Directory\my.ini
Global
Windows Directory\my.cnf
Global
c:\my.ini
Global
c:\my.cnf
Global
--defaults-file =path
Only read options from the given option file.
--defaults-extra-file =path
Read this extra option file after all other option files are read.
[client-server]
Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[server]
Options read by MariaDB Server.
[mysqld]
Options read by mysqld, including both MariaDB Server and MySQL Server.
[mysqld-X.Y]
Options read by a specific version of mysqld, including both MariaDB Server and MySQL Server. For example, [mariadb-11.4].
[mariadb]
Options read by MariaDB Server.
[mariadb-X.Y]
Options read by a specific version of MariaDB Server. For example, [mariadb-11.4].
[client]
Options read by all MariaDB and MySQL client programs, including both MariaDB and MySQL clients. For example, mariadb-dump.
[client-server]
Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[client-mariadb]
Options read by all MariaDB client programs.
[mysqld_safe]
Options read by mysqld_safe, including both MariaDB Server and MySQL Server.
[safe_mysqld]
Options read by mysqld_safe, including both MariaDB Server and MySQL Server.
[mariadbd-safe]
Options read by mysqld_safe from MariaDB Server.
[mariadb_safe]
Options read by mysqld_safe from MariaDB Server. Deprecated, please avoid using this.
[mariadb-backup]
Options read by mariadb-backup.
[xtrabackup]
Options read by mariadb-backup and Percona XtraBackup.
--defaults-group-suffix =suffix
In addition to the default option groups, also read option groups with the given suffix.
Read options from option files, print all option values, and then exit the program.
Sets the option value automatically. Only supported for certain options.
For all boolean options, disables the setting (equivalent to setting it to 0). Same as skip.
For all boolean options, enables the setting (equivalent to setting it to 1).
Don't produce an error if the option doesn't exist.
Sets the maximum value for the option.
For all boolean options, disables the setting (equivalent to setting it to 0). Same as disable.
installdir\my.ini
$program --help --verbose$ mariadbd --help --verbose
mariadbd Ver 10.11.2-MariaDB for linux-systemd on x86_64 (MariaDB Server)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Starts the MariaDB database server.
Usage: mariadbd [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-10.11 mariadb mariadb-10.11 mariadbd mariadbd-10.11 client-server galera
....echo %WINDIR%$program --help --verbose$ mariadbd --help --verbose
mariadbd Ver 10.11.2-MariaDB for linux-systemd on x86_64 (MariaDB Server)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Starts the MariaDB database server.
Usage: mariadbd [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-10.11 mariadb mariadb-10.11 mariadbd mariadbd-10.11 client-server galera
....[client_custom_group]
prompt='(custom prompt for mariadb client)'mariadb --defaults-group-suffix=_custom_group[mariadb]
...
!include /etc/mysql/dbserver1.cnf[mariadb]
...
!includedir /etc/my.cnf.d/$ mariadb-dump --print-defaults
mariadb-dump would have been started with the following arguments:
--ssl_cert=/etc/my.cnf.d/certificates/client-cert.pem --ssl_key=/etc/my.cnf.d/certificates/client-key.pem --ssl_ca=/etc/my.cnf.d/certificates/ca.pem --ssl-verify-server-cert --max_allowed_packet=1G$ my_print_defaults mariadb-dump client client-server client-mariadb
--ssl_cert=/etc/my.cnf.d/certificates/client-cert.pem
--ssl_key=/etc/my.cnf.d/certificates/client-key.pem
--ssl_ca=/etc/my.cnf.d/certificates/ca.pem
--ssl-verify-server-cert
--max_allowed_packet=1GB$ my_print_defaults --mysqld
--log_bin=mariadb-bin
--log_slave_updates=ON
--ssl_cert=/etc/my.cnf.d/certificates/server-cert.pem
--ssl_key=/etc/my.cnf.d/certificates/server-key.pem
--ssl_ca=/etc/my.cnf.d/certificates/ca.pem[mariadb]
...
# determine a good value for open_files_limit automatically
autoset_open_files_limit
# disable the unix socket plugin
disable_unix_socket
# enable the slow query log
enable_slow_query_log
# don't produce an error if these options don't exist
loose_file_key_management_filename = /etc/mysql/encryption/keyfile.enc
loose_file_key_management_filekey = FILE:/etc/mysql/encryption/keyfile.key
loose_file_key_management_encryption_algorithm = AES_CTR
# set max_allowed_packet to maximum value
maximum_max_allowed_packet
# disable external locking for MyISAM
skip_external_locking[client-server]
# Uncomment these if you want to use a nonstandard connection to MariaDB
#socket=/tmp/mysql.sock
#port=3306
# This will be passed to all MariaDB clients
[client]
#password=my_password
# The MariaDB server
[mysqld]
# Directory where you want to put your data
data=/usr/local/mysql/var
# Directory for the errmsg.sys file in the language you want to use
language=/usr/local/share/mysql/english
# This is the prefix name to be used for all log, error and replication files
log-basename=mysqld
# Enable logging by default to help find problems
general-log
log-slow-queries# Example mysql config file.
[client-server]
socket=/tmp/mysql-dbug.sock
port=3307
# This will be passed to all mariadb clients
[client]
password=my_password
# Here are entries for some specific programs
# The following values assume you have at least 32M ram
# The MariaDB server
[mysqld]
temp-pool
key_buffer_size=16M
datadir=/my/mysqldata
loose-innodb_file_per_table
[mariadb]
datadir=/my/data
default-storage-engine=aria
loose-mutex-deadlock-detector
max-connections=20
[mariadb-5.5]
language=/my/maria-5.5/sql/share/english/
socket=/tmp/mysql-dbug.sock
port=3307
[mariadb-10.1]
language=/my/maria-10.1/sql/share/english/
socket=/tmp/mysql2-dbug.sock
[mysqldump]
quick
max_allowed_packet=16M
[mysql]
no-auto-rehash
loose-abort-source-on-error