MySQL Router 9.1  /  Configuration  /  Configuration File Syntax

4.1 Configuration File Syntax

The configuration file format resembles the traditional INI file format with sections and options, but with a few additional extensions.

Note

Both forward slashes and backslashes are supported. Backslashes are unconditionally copied, as they do not escape characters.

Comments

The configuration file can contain comment lines. Comment lines start with a hash (#) or semicolon (;) and continue to the end of the line. Trailing comments are not supported.

Sections

Each configuration file consists of a list of configuration sections where each section contains a sequence of configuration options. Each configuration option has a name and value. For example:

[section name]
option = value
option = value
option = value

[section name:optional section key]

option = value
option = value
option = value

A configuration file section header starts with an opening bracket ([) and ends with a closing bracket (]). There can be leading and trailing space characters on the line, which are ignored, but no space inside the section brackets.

The section header inside the brackets consists of a section name and an optional section key that is separated from the section header with a colon (:). The combination of section name and section key is unique for a configuration.

The section names and section keys consist of a sequence of one or more letters, digits, or underscores (_). No other characters are allowed in the section name or section key.

A section is similar to a namespace. For example, the user option's meaning depends on its associated section. A user in the [DEFAULT] section refers to the system user that MySQL Router is run as, which is also controlled by the --user command line option. Unrelated to that is defining user in the [metadata_cache] section, which refers to the MySQL user that accesses a MySQL server's metadata.

Default Section

The special section name DEFAULT (any case) is used for default values for options. Options not found in a section are looked up in the default section. The default section does not accept a section key.

Options

After a section's start header, there can be a sequence of zero or more option lines where each option line is of the form:

name = value

Any leading or trailing blank characters on the option name or option value are removed before being handled. Option names are case-insensitive. Trailing comments are not supported, so in this example the option routing_strategy is given the value round-robin # Circles back to first server and generates an error when starting the router.

[routing:round-robin]
# Trailing comments are not supported so the following is incorrect
routing_strategy=round-robin # Circles back to first server

Variable Interpolation

Option values support (variable interpolation) using an option name given within braces { and }. Interpolation is done on retrieval of the option value and not when it is read from the configuration file. If a variable is not defined then no substitutions are done and the option value is read literally.

Consider this sample configuration file:

[DEFAULT]
prefix = /usr/

[sample]
bin = {prefix}bin/{name}
lib = {prefix}lib/{name}
name = magic
directory = C:\foo\bar\{3a339172-6898-11e6-8540-9f7b235afb23}

Here the value of bin is "/usr/bin/magic", the value of lib is "/usr/lib/magic", and the value of directory is "C:\foo\bar\{3a339172-6898-11e6-8540-9f7b235afb23}" because a variable named "{3a339172-6898-11e6-8540-9f7b235afb23}" is not defined.

Predefined variables

MySQL Router defines predefined variables that are available to the configuration file. Variables use braces, such as {program} for the program predefined variable.

Table 4.1 Predefined variables

Name Description
program Name of the program, normally mysqlrouter
origin Path to directory where binary is located
logging_folder Path to folder for log files
plugin_folder Path to folder for plugins
runtime_folder Path to folder for runtime data
config_folder Path to folder for configuration files

Command Line Related Details

For command-line syntax related information and options, see Section 4.3.1, “Defining Options Using the Command Line”.