All pages
Powered by GitBook
1 of 10

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Advanced Configuration

Dive into advanced configurations for MariaDB Server performance. This section covers in-depth tuning parameters, optimization strategies, and best practices to maximize speed and efficiency.

Articles of how to setup your MariaDB optimally on different systems

Fusion-io

Introduction to using Fusion-io flash memory cards with MariaDB to significantly boost I/O throughput and reduce latency, including benefits like atomic write support.

Configuring MariaDB

Learn how to configure MariaDB Server. This section covers essential configuration options, system variables, and best practices for tuning your database for optimal performance and security.

Configuring Linux for MariaDB

Guidance on tuning Linux kernel settings for MariaDB performance, including I/O schedulers (using `none` or `mq-deadline`), open file limits, and core file sizes.

Linux kernel settings

IO scheduler

For optimal IO performance running a database on modern hardware we recommend using the none (previously called noop) scheduler.

Recommended schedulers are none, for SSDs and NVMes, and mq-deadline (previously called deadline) for hard disks.

You can check your scheduler setting with:

For instance, it should look like this output:

Older kernels may look like:

Writing the new scheduler name to the same /sys node will change the scheduler:

The impact of schedulers depend significantly on workload and hardware. You can measure the IO-latency using the bcc-tools script with an aim to keep the mean as low as possible.

Resource Limits

Configuring the Open Files Limit

By default, the system limits how many open file descriptors a process can have open at one time. It has both a soft and hard limit. On many systems, both the soft and hard limit default to 1024. On an active database server, it is very easy to exceed 1024 open file descriptors. Therefore, you may need to increase the soft and hard limits. There are a few ways to do so.

If you are using to start mysqld, then see the instructions at .

If you are using to start mysqld, then see the instructions at .

Otherwise, you can set the soft and hard limits for the mysql user account by adding the following lines to :

After the system is rebooted, the mysql user should use the new limits, and the user's ulimit output should look like the following:

Configuring the Core File Size

By default, the system limits the size of core files that could be created. It has both a soft and hard limit. On many systems, the soft limit defaults to 0. If you want to , then you may need to increase this. Therefore, you may need to increase the soft and hard limits. There are a few ways to do so.

If you are using to start mysqld, then see the instructions at .

If you are using to start mysqld, then see the instructions at .

Otherwise, you can set the soft and hard limits for the mysql user account by adding the following lines to :

After the system is rebooted, the mysql user should use the new limits, and the user's ulimit output should look like the following:

Swappiness

See .

This page is licensed: CC BY-SA / Gnu FDL

MariaDB Environment Variables

Reference for environment variables that affect MariaDB configuration, such as MYSQL_HOME and LD_PRELOAD, and how they interact with option files.

MariaDB makes use of numerous environment variables that may be set on your system. Environment variables have the lowest precedence, so any options set on the command line or in an option file will take precedence.

It's usually better not to rely on environment variables, and to rather set the options you need directly, as this makes the system a little more robust and easy to administer.

Here is a list of environment variables used by MariaDB:

Environment Variable
Description

DBI_USER

Perl DBI default username.

DBI_TRACE

Perl DBI trace options.

HOME

Default directory for the .

MYSQL_DEBUG

Debug trace options used when debugging.

MYSQL_GROUP_SUFFIX

In addition to the given option groups, also read groups with this suffix.

MYSQL_HISTFILE

Path to the , overriding the $HOME/.mysql_history setting.

MYSQL_HOME

Path to the directory containing the used by the server.

MYSQL_HOST

Default host name used by the .

MYSQL_PS1

Command prompt for use by the .

MYSQL_PWD

Default password when connecting to mysqld. It is strongly recommended to use a more secure method of sending the password to the server.

MYSQL_TCP_PORT

Default TCP/IP port number.

MYSQL_UNIX_PORT

On Unix, default socket file used for localhost connections.

PATH

Path to directories that hold executable programs (such as the , ), so that these can be run from any location.

TMPDIR

Directory where temporary files are created.

TZ

Local .

UMASK

Creation mode when creating files. See .

UMASK_DIR

Creation mode when creating directories. See .

USER

On Windows, up to , the default user name when connecting to the mysqld server. API GetUserName() is used in later versions.

This page is licensed: CC BY-SA / Gnu FDL

CXX

Name of the C++ compiler, used for running CMake.

CC

Name of the C compiler, used for running CMake.

biolatency
mysqld_safe or mariadbd-safe
mariadbd-safe: Configuring the Open Files Limit
systemd
systemd: Configuring the Open Files Limit
/etc/security/limits.conf
mysqld_safe or mariadbd-safe
mariadb-safe: Configuring the Core File Size
systemd
systemd: Configuring the Core File Size
/etc/security/limits.conf
configuring swappiness

Atomic Write Support

Explains the concept of atomic writes in MariaDB, which improve performance and data integrity on SSDs by bypassing the InnoDB doublewrite buffer, supported on devices like Fusion-io and Shannon SSDs.

Partial Write Operations

When Innodb writes to the filesystem, there is generally no guarantee that a given write operation will be complete (not partial) in cases of a poweroff event, or if the operating system crashes at the exact moment a write is being done.

Without detection or prevention of partial writes, the integrity of the database can be compromised after recovery.

innodb_doublewrite--an Imperfect Solution

Since its inception, Innodb has had a mechanism to detect and ignore partial writes via the (also innodb_checksum can be used to detect a partial write).

Doublewrites, controlled by the system variable, comes with its own set of problems. Especially on SSD, writing each page twice can have detrimental effects (write leveling).

Atomic Write - a Faster Alternative to innodb_doublewrite

A better solution is to directly ask the filesystem to provide an atomic (all or nothing) write guarantee. Currently this is only available on .

Enabling Atomic Writes from

When starting, and beyond automatically detects if any of the supported SSD cards are used.

When opening an InnoDB table, there is a check if the tablespace for the table is and if yes, it will automatically enable atomic writes for the table. If atomic writes support is not detected, the doublewrite buffer will be used.

One can disable atomic write support for all cards by setting the variable to OFF in your my.cnf file. It's ON by default.

Enabling Atomic Writes in to

To use atomic writes instead of the doublewrite buffer, add:

to the my.cnf config file.

Note that atomic writes are only supported on in these versions of MariaDB.

About innodb_use_atomic_writes (in to )

The following happens when atomic writes are enabled

  • if is neither O_DIRECT, ALL_O_DIRECT, or O_DIRECT_NO_FSYNC, it is switched to O_DIRECT

  • is switched ON (files are extended using posix_fallocate rather than writing zeros behind the end of file)

Here is a flowchart showing how atomic writes work inside InnoDB:

Devices that Support Atomic Writes with MariaDB

MariaDB currently supports atomic writes on the following devices:

  • . and above.

  • . and above.

This page is licensed: CC BY-SA / Gnu FDL

cat /sys/block/${DEVICE}/queue/scheduler
cat /sys/block/vdb/queue/scheduler
[none] mq-deadline kyber bfq
cat /sys/block/sda/queue/scheduler
[noop] deadline cfq
echo noop >  /sys/block/vdb/queue/scheduler
mysql soft nofile 65535
mysql hard nofile 65535
$ ulimit -Sn
65535
$ ulimit -Hn
65535
mysql soft core unlimited
mysql hard core unlimited
$ ulimit -Sc
unlimited
$ ulimit -Hc
unlimited

Whenever an Innodb datafile is opened, a special ioctl() is issued to switch on atomic writes. If the call fails, an error is logged and returned to the caller. This means that if the system tablespace is not located on an atomic write capable device or filesystem, InnoDB/XtraDB will refuse to start.

  • if innodb_doublewrite is set to ON, innodb_doublewrite will be switched OFF and a message written to the error log.

  • InnoDB Doublewrite Buffer
    innodb_doublewrite
    a few SSD cards
    on a device that supports atomic writes
    innodb-use-atomic-writes
    Fusion-io devices that use the NVMFS file system
    innodb_flush_method
    innodb_use_fallocate
    Fusion-io devices with the NVMFS file system
    Shannon SSD
    Atomic write support flow inside InnoDB
    mysql_history file
    mysql_history file
    my.cnf file
    mariadb command line client
    mariadb command line client
    mariadb client
    mariadb-admin
    time zone
    Specifying Permissions for Schema (Data) Directories and Tables
    Specifying Permissions for Schema (Data) Directories and Tables

    Fusion-io Introduction

    Fusion-io develops PCIe based NAND flash memory cards and related software that can be used to speed up MariaDB databases.

    The ioDrive branded products can be used as block devices (super-fast disks) or to extend basic DRAM memory. ioDrive is deployed by installing it on an x86 server and then installing the card driver under the operating system. All main line 64-bit operating systems and hypervisors are supported: RHEL, CentOS, SuSe, Debian, OEL etc. and VMware, Microsoft Windows/Server etc. Drivers and their features are constantly developed further.

    ioDrive cards support software RAID and you can combine two or more physical cards into one logical drive. Through ioMemory SDK and its APIs, one can integrate and enable more thorough interworking between your own software and the cards - and cut latency.

    The key differentiator between a Fusion-io and a legacy SSD/HDD is the following: A Fusion-io card is connected directly on the system bus (PCIe), this enables high data transfer throughput (1.5 GB/s, 3.0 GB/s or 6GB/s) and the fast direct memory access (DMA) method can be used to transfer data. The ATA/SATA protocol stack is omitted and therefore latency is cut short. Fusion-io performance is dependent on server speed: the faster processors and the newer PCIe-bus version you have, the better is the ioDrive performance. Fusion-io memory is non-volatile, in other words, data remains on the card even when the server is powered off.

    Use Cases

    1. You can start by using ioDrive for database files that need heavy random access.

    2. Whole database on ioDrive.

    3. In some cases, Fusion-io devices allow for atomic writes, which allows the server to safely disable the .

    4. Use ioDrive as a write-through read cache. This is possible on server level with Fusion-io directCache software or in VMware environments using ioTurbine software or the ioCache bundle product. Reads happen from ioDrive and all writes go directly to your SAN or disk.

    Atomic Writes

    Starting with , MariaDB Server supports atomic writes on Fusion-io devices that use the NVMFS (formerly called DirectFS) file system. Unfortunately, NVMFS was never offered under ‘General Availability’, and SanDisk declared that NVMFS would reach end-of-life in December 2015. Therefore, NVMFS support is no longer offered by SanDisk.

    MariaDB Server does not currently support atomic writes on Fusion-io devices with any other file systems.

    See for more information about MariaDB Server's atomic write support.

    Future Suggested Development

    • Extend InnoDB disk cache to be stored on Fusion-io acting as extended memory.

    Settings For Best Performance

    Fusion-io memory can be formatted with different sector size of either 512 or 4096 bytes. Bigger sectors are expected to be faster, but only if I/O is done in blocks of 4KB or multiples of that. Speaking of MariaDB: if only InnoDB data files are stored in Fusion-io memory, all I/O is done in blocks of 16K and thus 4K sector size can be used. If the InnoDB redo log (I/O block size: 512 bytes) goes to the same Fusion-io memory, then short sectors should be used.

    Note: XtraDB has the experimental feature of an increased InnoDB log block size of 4K. If this is enabled, then both redo log I/O and page I/O in InnoDB will match a sector size of 4K.

    As of file systems: currently XFS is expected to yield the best performance with MariaDB. However depending on the exact kernel version and version of XFS code in use, one might be affected by . This has or (because of .

    For the pitbull machine where I have run such tests, ext4 was faster than xfs for 32 or more threads:

    • up to 8 threads xfs was few percent faster (10% on average).

    • at 16 threads it was a draw (2036 tps vs. 2070 tps).

    • at 32 threads ext4 was 28% faster (2345 tps vs. 1829 tps).

    • at 64 threads ext4 was even 47% faster (2362 tps vs. 1601 tps).

    Those numbers are for spinning disks. I guess for Fusion-io memory the XFS numbers will be even worse.

    Example Configuration

    Card Models

    There are several card models. ioDrive is older generation, ioDrive2 is newer. SLC sustains more writes. MLC is good enough for normal use.

    1. ioDrive2, capacities per card 365GB, 785GB, 1.2TB with MLC. 400GB and 600GB with SLC, performance up to 535000 IOPS & 1.5GB/s bandwidth

    2. ioDrive2 Duo, capacities per card 2.4TB MLC and 1.2TB SLC, performance up to 935000 IOPS & 3.0GB/s bandwidth

    3. ioDrive, capacities per card 320GB, 640GB MLC and 160GB, 320GB SLC, performance up to 145000 IOPS & 790MB/s bandwidth

    4. ioDrive Duo, capacities per card 640GB, 1.28TB MLC and 320GB, 640GB SLC, performance up to 285000 IOPS & 1.5GB/s bandwidth

    Additional Software

    • directCache - transforms ioDrive to work as a read cache in your server. Writes go directly to your SAN

    • ioTurbine - read cache software for VMware

    • ION - transforms ioDrive into a shareable storage

    • ioSphere - software to manage and monitor several ioDrives

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    Configuring Swappiness

    Recommendations for setting the Linux `vm.swappiness` kernel parameter (ideally to 1) to prevent the OS from swapping out MariaDB memory pages, which degrades performance.

    Why to Avoid Swapping

    Obviously, accessing swap memory from disk is far slower than accessing RAM directly. This is particularly bad on a database server because:

    • MariaDB's internal algorithms assume that memory is not swap, and are highly inefficient if it is. Some algorithms are intended to avoid or delay disk IO, and use memory where possible - performing this with swap can be worse than just doing it on disk in the first place.

    innodb_use_atomic_writes = 1

    Highly Available shared storage with ION. Have two different hosts, Fusion-io cards in them and share/replicate data with Fusion-io's ION software.

  • The luxurious Platinum setup: MariaDB Galera Cluster running on Fusion-io SLC cards on several hosts.

  • at higher concurrency ext4 lost its bite, but was still constantly better than xfs.

    ioDrive Octal, capacities per card 5TB and 10TB MLC, performance up to 1350000 IOPS & 6.7GB/s bandwidth

  • ioFX, a 420GB QDP MLC workstation product, 1.4GB/s bandwidth

  • ioCache, a 600GB MLC card with ioTurbine software bundle that can be used to speed up VMware based virtual hosts.

  • ioScale, 3.2TB card, building block to enable all-flash data center build out in hyperscale web and cloud environments. Product has been developed in co-operation with Facebook.

  • doublewrite buffer
    atomic write support
    a bug that severely limits XFS performance in concurrent environments
    been fixed in kernel versions above 3.5
    RHEL6 kernels kernel-2.6.32-358 or later
    bug 807503 being fixed)
    FusionIO atomic-series devices
    GE-Fusionio-MariaDB

    Swap increases IO over just using disk in the first place as pages are actively swapped in and out of swap. Even something like removing a dirty page that is no longer going to be stored in memory, while designed to improve efficiency, will under a swap situation cost more IO.

  • Database locks are particularly inefficient in swap. They are designed to be obtained and released often and quickly, and pausing to perform disk IO will have a serious impact on their usability.

  • The main way to avoid swapping is to make sure you have enough RAM for all processes that need to run on the machine. Setting the system variables too high can mean that under load the server runs short of memory, and needs to use swap. So understanding what settings to use and how these impact your server's memory usage is critical.

    Setting Swappiness on Linux

    Linux has a swappiness setting which determines the balance between swapping out pages (chunks of memory) from RAM to a preconfigured swap space on the hard drive.

    The setting is from 0 to 100, with lower values meaning a lower likelihood of swapping. The default is usually 60 --you can check this by running:

    The default setting encourages the server to use swap. Since there probably won't be much else on the database server besides MariaDB processes to put into swap, you'll probably want to reduce this to zero to avoid swapping as much as possible. You can change the default by adding a line to the sysctl.conf file (usually found in /etc/sysctl.conf).

    To set the swappiness to zero, add the line:

    This normally takes effect after a reboot, but you can change the value without rebooting as follows:

    Since RHEL 6.4, setting swappiness=0 more aggressively avoids swapping out, which increases the risk of OOM killing under strong memory and I/O pressure.

    A low swappiness setting is recommended for database workloads. For MariaDB databases, it is recommended to set swappiness to a value of 1.

    Disabling Swap Altogether

    While some disable swap altogether, and you certainly want to avoid any database processes from using it, it can be prudent to leave some swap space to at least allow the kernel to fall over gracefully should a spike occur. Having emergency swap available at least allows you some scope to kill any runaway processes.

    This page is licensed: CC BY-SA / Gnu FDL

    sysctl vm.swappiness
    vm.swappiness = 0
    sysctl -w vm.swappiness=0
    vm.swappiness = 1

    Configuring MariaDB for Optimal Performance

    Best practices for configuring MariaDB server variables like `innodb_buffer_pool_size`, `aria_pagecache_buffer_size`, and `thread_handling` to maximize resource utilization on dedicated servers.

    This article will help you configure MariaDB for optimal performance.

    By default, MariaDB is configured to work on a desktop system and therefore use relatively few resources. To optimize installation for a dedicated server, you have to do a few minutes of work.

    For this article we assume that you are going to run MariaDB on a dedicated server.

    Feel free to update this article if you have more ideas.

    my.cnf Files

    MariaDB is normally configured by editing the my.cnf file. In the next section you have a list of variables that you may want to configure for dedicated MariaDB servers.

    Storage Engine

    InnoDB is normally the default storage engine with MariaDB.

    • You should set to about 80% of your memory. The goal is to ensure that 80 % of your working set is in memory.

    The other most important InnoDB variables are:

    Some other important InnoDB variables:

    • . Deprecated and ignored from .

    • . Deprecated and ignored from .

    Storage Engine

    • MariaDB uses by default the Aria storage engine for internal temporary files. If you have many temporary files, you should set to a reasonably large value so that temporary overflow data is not flushed to disk. The default is 128M.

    You can check if Aria is configured properly by executing:

    If Aria_pagecache_reads is much smaller than Aria_pagecache_read_request andAria_pagecache_writes is much smaller than Aria_pagecache_write_request#, then your setup is good. If the is big enough, the two variables should be 0, like above.

    • If you don't use MyISAM tables explicitly (true for most + users), you can set to a very low value, like 64K.

    Using in memory temporary tables

    Using memory tables for internal temporary results can speed up execution. However, if the memory table gets full, then the memory table will be moved to disk, which can hurt performance.

    You can check how the internal memory tables are performing by executing:

    Created_tmp_tables is the total number of internal temporary tables created as part of executing queries like SELECT.Created_tmp_disk_tables shows how many of these did hit the storage.

    You can increase the storage for internal temporary tables by setting and high enough. These values are per connection.

    Lots of Connections

    A Lot of Fast Connections + Small Set of Queries + Disconnects

    • If you are doing a lot of fast connections / disconnects, you should increase and if you are running or below .

    • If you have a lot (> 128) of simultaneous running fast queries, you should consider setting to pool_of_threads.

    Connecting From a Lot of Different Machines

    • If you are connecting from a lot of different machines you should increase to the max number of machines (default 128) to cache the resolving of hostnames. If you don't connect from a lot of machines, you can set this to a very low value!

    See Also

    External Links

    This page is licensed: CC BY-SA / Gnu FDL

    innodb_thread_concurrency. Deprecated and ignored from .

    Performance schema helps you understand what is taking time and resources.
  • Slow query log is used to find queries that are running slow.

  • OPTIMIZE TABLE helps you defragment tables.

  • InnoDB
    innodb_buffer_pool_size
    innodb_log_file_size
    innodb_flush_method
    innodb_thread_sleep_delay
    innodb_max_dirty_pages_pct_lwm
    innodb_read_ahead_threshold
    innodb_buffer_pool_instances
    innodb_adaptive_max_sleep_delay
    Aria
    aria_pagecache_buffer_size
    aria_pagecache_buffer_size
    MyISAM
    key_buffer_size
    max_heap_table_size
    tmp_memory_table_size
    back_log
    thread_cache_size
    thread_handling
    host_cache_size
    MariaDB Memory Allocation
    Full List of MariaDB Options, System and Status Variables
    Server system variables
    mysqld options
    what-to-tune-in-mysql-56-after-installation.html
    optimizing-mysql-configuration-percona-mysql-university-montevideo

    Configuring MariaDB with Option Files

    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.

    Global Options Related to Option Files

    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:

    Option
    Description

    Default Option File Locations

    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.

    Default Option File Locations on Linux, Unix, Mac

    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:

    Location
    Scope
    • If the DEFAULT_SYSCONFDIR cmake option is defined, MariaDB looks for the MariaDB option file in the following locations in the following order:

    Location
    Scope
    • 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.

    Default Option File Locations on Windows

    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:

    Location
    Scope
    • 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.

    Default Option File Hierarchy

    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.

    Custom Option File Locations

    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:

    Option
    Description

    Option File Syntax

    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.

    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:

    Server Option Groups

    MariaDB programs reads server options from the following server option groups:

    Group
    Description

    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.

    Client Option Groups

    MariaDB programs reads client options from the following option groups:

    Group
    Description

    Tool-Specific Option Groups

    Many MariaDB tools reads options from their own option groups as well:

    Group
    Description

    Custom Option Group Suffixes

    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:

    Option
    Description

    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:

    Including Option Files

    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:

    Including Option File Directories

    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.

    Checking Program Options

    You can check which options a given program is going to use by using the command-line argument:

    Option
    Description

    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 :

    Obfuscated Authentication Credential Option File

    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.

    Option Prefixes

    MariaDB supports certain prefixes that can be used with options. The supported option prefixes are:

    Option Prefix
    Description

    For example:

    Options

    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

    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

    MariaDB client options can be set in .

    See the specific page for each to determine what options are available for that program.

    Example Option Files

    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.

    Example Minimal Option File

    Minimal my.cnf file that you can use to test MariaDB:

    Example Hybrid Option File

    The following is an extract of an option file that one can use if one wants to work with both MySQL and MariaDB.

    See Also

    This page is licensed: CC BY-SA / Gnu FDL

    MariaDB [test]> show global status like "Aria%";
    +-----------------------------------+-------+
    | Variable_name                     | Value |
    +-----------------------------------+-------+
    | Aria_pagecache_blocks_not_flushed | 0     |
    | Aria_pagecache_blocks_unused      | 964   |
    | Aria_pagecache_blocks_used        | 232   |
    | Aria_pagecache_read_requests      | 9598  |
    | Aria_pagecache_reads              | 0     |
    | Aria_pagecache_write_requests     | 222   |
    | Aria_pagecache_writes             | 0     |
    | Aria_transaction_log_syncs        | 0     |
    +-----------------------------------+-------+
    MariaDB [test]> show global status like "Created%tables%";
    +-------------------------+-------+
    | Variable_name           | Value |
    +-------------------------+-------+
    | Created_tmp_disk_tables | 1     |
    | Created_tmp_tables      | 2     |
    +-------------------------+-------+
    is set to the MariaDB data directory.
  • 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

    is in
    C:\Program Files\
    ,
    INSTALLDIR
    is
    C:\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 same option group can appear multiple times.
  • 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.

    --print-defaults

    Read options from option files, print all option values, and then exit the program.

    --no-defaults

    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.

    --print-defaults

    Read options from option files, print all option values, and then exit the program.

    autoset

    Sets the option value automatically. Only supported for certain options.

    disable

    For all boolean options, disables the setting (equivalent to setting it to 0). Same as skip.

    enable

    For all boolean options, enables the setting (equivalent to setting it to 1).

    loose

    Don't produce an error if the option doesn't exist.

    maximum

    Sets the maximum value for the option.

    skip

    For all boolean options, disables the setting (equivalent to setting it to 0). Same as disable.

    cmake
    RPM packages
    DEB packages
    binary tarballs
    environment variable
    mysqld_safe
    GetSystemWindowsDirectory
    cmd.exe
    --defaults-file
    Server System Variables
    --log-basename
    --log-basename
    mariadbd
    Option Groups
    mariadbd
    environment variable
    --print-defaults
    mariadbd
    my_print_defaults
    server option groups
    mysql_config_editor
    server option groups
    mariadbd
    server system variables
    client option groups
    client program
    Troubleshooting Connection Issues
    Configuring MariaDB for Remote Client Access

    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
    --defaults-extra-file
    mysql_upgrade
    mariadb-upgrade
    mysql
    mariadb
    mysqldump
    mariadb-dump
    mysqlimport
    mariadb-import
    mysqlbinlog
    mariadb-binlog
    mysqladmin
    mariadb-admin
    mysqlshow
    mariadb-show
    mariadb-check
    mariadb-check
    mysqlslap
    mariadb-slap
    Galera Cluster
    enable core dumps
    MariaDB 10.2
    MariaDB 10.2
    MariaDB 5.5
    MariaDB 10.1
    MariaDB 5.5
    MariaDB 10.1
    MariaDB 5.5
    MariaDB 10.2
    MariaDB 5.5
    MariaDB 5.5.31
    MariaDB 10.5.1
    MariaDB 10.5.5
    MariaDB 10.4
    MariaDB 10.1
    MariaDB 10.5.5
    Configuring MariaDB Connector/C with Option Files
    MariaDB Connector/ODBC
    USE_MYCNF
    mariadb-backup SST method