The configuration file format resembles the traditional INI file format with sections and options, but with a few additional extensions.
Both forward slashes and backslashes are supported. Backslashes are unconditionally copied, as they do not escape characters.
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 arenot supported.
Each configuration file consists of a list ofconfiguration sections where each section contains a sequence ofconfiguration options. Each configuration option has a name and value. For example:
[section name]option =valueoption =valueoption =value[section name:optional section key]option =valueoption =valueoption =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 asection name and an optionalsection 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, theuser option's meaning depends on its associated section. Auser 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 defininguser in the[metadata_cache] section, which refers to the MySQL user that accesses a MySQL server's metadata.
The special section nameDEFAULT (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.
After a section's start header, there can be a sequence of zero or moreoption 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 optionrouting_strategy is given the valueround-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 incorrectrouting_strategy=round-robin # Circles back to first server 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 = magicdirectory = C:\foo\bar\{3a339172-6898-11e6-8540-9f7b235afb23} Here the value ofbin is "/usr/bin/magic", the value oflib is "/usr/lib/magic", and the value ofdirectory is "C:\foo\bar\{3a339172-6898-11e6-8540-9f7b235afb23}" because a variable named "{3a339172-6898-11e6-8540-9f7b235afb23}" is not defined.
MySQL Router defines predefined variables that are available to the configuration file. Variables use braces, such as{program} for theprogram predefined variable.
Table 4.1 Predefined variables
| Name | Description |
|---|---|
program | Name of the program, normallymysqlrouter |
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 |
For command-line syntax related information and options, seeSection 4.3.1, “Defining Options Using the Command Line”.