How to determine the location and name of the MySQL (MariaDB) configuration file. How to find the group name for MySQL and MariaDB configuration files

MySQL and MariaDB config files

Some useful settings that improve productivity or solve problems that have arisen should be saved in configuration files. But you may encounter a situation where some online guide recommends saving the settings to a file located in a certain directory, but in your Linux this file or even the entire directory is missing. The confusion is further increased by the proliferation of both MySQL and a fork called MariaDB, which largely replicates the original DBMS, but has its own nuances.

How to proceed in this case? Do I need to create a new directory and files for MySQL and MariaDB settings? How do group names differ for config files in MySQL and MariaDB? This article will answer all these questions.

You can specify MySQL and MariaDB program options in several ways, for example, on the command line, in environment variables, in settings files. There is a priority for options specified in different ways, you can read more about this at the link: https://dev.mysql.com/doc/refman/8.1/en/option-files.html

In this note, we will only touch on files with settings.

How to find out where the MySQL (MariaDB) settings file is located

MySQL (MariaDB) programs show the location of configuration files in the first lines of the help display:

mysql --help

mariadb --help

Example output:

Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf

Example output on another version of Linux:

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

As you can see, MySQL and MariaDB use multiple configuration files. You may also have noticed the note that files are read in the order listed – this is important if the files contain mutually exclusive settings for the same options.

Recall that the symbol “~” denotes the home directory of the current user.

In fact, there are usually even more configuration files, since the already specified files may contain an “include” directive, for example:

!includedir /etc/my.cnf.d

If a directory is specified (as in the example above), then the settings will be read from all *.cnf files from the specified directory.

A specific file can also be specified:

!include /home/mydir/myopt.cnf

How to find group names for MySQL and MariaDB settings files

In addition to the main service and client, the MySQL and MariaDB packages include quite a lot of programs. MySQL and MariaDB allow you to combine settings for different utilities in one configuration file. In order for programs to correctly determine which settings belong to which programms, group names are used inside files, for example:






The group names for MySQL and MariaDB are different. To find out what group names your version of the DBMS uses, run the help and pay attention to the first lines of the output:

mysql --help

mariadb --help

Example output:

The following groups are read: mysql mariadb-client client client-server client-mariadb

Then, when setting up the client and server of this version of the DBMS, you can use the following names of settings groups:






Please note that group names are shown for the client only and only for the MySQL/MariaDB server. Even if they are not listed, you can also use group names that include the names of other programs, for example:



Leave Your Observation

Your email address will not be published. Required fields are marked *