MariaDB global settings

MariaDB main config file

It is quite common on Linux systems to come across with simple text files acting as global settings for different tools, that is also the case of MariaDB, and as you can imagine the name of the file and also the location still the same as in MySQL.

my.cnf

Same as in MySQL the MariaDB main config file is called “my.cnf” and is located inside the “/etc” folder.

MariaDB main configuration file – my.cnf

How to open my.cnf with WinSCP

As you can see in the below animation you can take advantage of the WinSCP bookmarks to go directly to the folder where you can open the file by just double clicking.

MariaDB my.cnf

How to open my.cnf with vi

Those of you who prefer the terminal can use the following CLI command to open the file “my.cnf” with “vi”

vi /etc/my.cnf

MariaDB default settings

Here you can see the default settings found on a fresh MariaDB installation, from now on it’s quite probably that this file start growing depending on the modifications you may want to made, just as an example, if you want to enable the “binary log” this is the file where that change is made (below the mysqld section).

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

If you decide to move the database to a different folder you must modify this file accordingly as well as SELinux security policy and also the security context of the new directory.

my.cnf.d (the include) directory

MariaDB has an specific directory intended for keeping all the configuration files, by the default you are going to find the following three files.

MariaDB configuration files

You can add more configuration files inside this folder, just be sure to end their names with the “.cnf” extension in order for them to be processed as such.

.cnf extension is mandatory

Error log file

Below the [mysqld_safe] section you can see the name and location of the error log file “mariadb.log”, you can use “cat” and “grep” as follow to see only this particular line.

cat /etc/my.cnf | grep log 
MariaDB error log file “mariadb.log”

Binary Logs

Binary Logs are disabled by default, you may want to enable them when doing troubleshooting as this brings to light a bunch of useful information, in our case the binary log is still disable as you can see in the following image.

mariadb show binary logs

We are going to cover the “binary logs” in further articles when troubleshooting MariaDB.