MySQL Router scans for the default configuration files at startup, and optionally loads user-defined configuration files at runtime from the command line.
By default, MySQL Router scans specific locations for its configuration files, depending on the platform and how MySQL Router was set up.
You can alter the default locations at compile time by using the
-DROUTER_CONFIGDIR=<path> option. You
could also edit
change the default locations before compiling MySQL Router, thus
adding new locations or exceptions for specific platforms.
mysqlrouter --help to see the default
configuration file locations (and their availability) on your
system. For example:
shell> mysqlrouter --help MySQL Router v2.1.4 on macOS v10.12 (64-bit) (GPL community edition) Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Start MySQL Router. Configuration read from the following files in the given order (enclosed in parentheses means not available for reading): (/usr/local/mysql-router/mysqlrouter.conf) /Users/philip/.mysqlrouter.conf Plugins Path: /usr/local/lib/mysqlrouter Default Log Directory: /usr/local/mysql-router Default Persistent Data Directory: /usr/local/mysql-router/data Default Runtime State Directory: /usr/local/mysql-router/run Usage: mysqlrouter [-v|--version] [-h|--help] ...
The default configuration file is not loaded if a user-defined
configuration file is passed in with the
On Linux, by default MySQL Router scans the following locations, although these locations are system dependent:
Unlike MySQL server, the backward compatible path "
/etc/mysqlrouter.conf" is not supported.
For backward compatibility, MySQL Router also looks for the .ini variant in each directory. In doing so, Router looks in the initial directory for the .conf version, then checks for a .ini version, and then repeats the process in the next directory which is typically the user's home directory on the system.
Two command line options help control these configuration file locations:
-c): Read the base configuration from this file, and not use or scan the default file paths.
Common use: when generating a standalone MySQL Router installation with the
--directorybootstrap option, the generated
start.shpasses this option to the generated
mysqlrouter.confinside that directory.
shell> mysqlrouter -c /custom/path/to/router.conf -a /another/config.conf
Multiple extra configuration options can be passed in and the
files are loaded in the order they are entered, with
--config options being loaded before the
--extra-config options. For example:
shell> mysqlrouter --extra-config a.conf --config b.conf --extra-config c.conf
In the above example,
b.conf is loaded
first, and then
c.conf, in that order. In addition, the
default configuration file, such as
/etc/mysqlrouter/mysqlrouter.conf, is not
--config was used.
Each loaded configuration file overrides configuration settings from the previously read configuration files.
The following lists default file location for the router to read configuration files on popular Linux platforms.
mysqlrouter --help to see the
default configuration file locations (and their availability)
on your system.
Default system-wide installation under
RPM and Debian :
On all systems, a bootstrapped standalone installation using
mysqlrouter.confinto the directory defined by --directory.