MySQL Router 2.1  /  Configuration  /  Configuration File Locations

4.2 Configuration File Locations

MySQL Router scans for the default configuration files at startup, and optionally loads user-defined configuration files at runtime from the command line.

Default Configuration File Locations

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 cmake/settings.cmake to change the default locations before compiling MySQL Router, thus adding new locations or exceptions for specific platforms.

Execute 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

Start MySQL Router.

Configuration read from the following files in the given order (enclosed
in parentheses means not available for reading):
Plugins Path:
Default Log Directory:
Default Persistent Data Directory:
Default Runtime State Directory:

Usage: mysqlrouter [-v|--version] [-h|--help]


The default configuration file is not loaded if a user-defined configuration file is passed in with the --config option.

On Linux, by default MySQL Router scans the following locations, although these locations are system dependent:

  1. /etc/mysqlrouter/mysqlrouter.conf


    Unlike MySQL server, the backward compatible path "/etc/mysqlrouter.conf" is not supported.

  2. $HOME/.mysqlrouter.conf


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.

User-Defined and Extra Configuration Files

Two command line options help control these configuration file locations:

  • --config (or -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 --directory bootstrap option, the generated passes this option to the generated mysqlrouter.conf inside that directory.

  • --extra-config (or -a): Read this additional configuration file after the configuration files are read from either the default locations, or from files specified using the --config option.

For example:

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 a.conf and c.conf, in that order. In addition, the default configuration file, such as /etc/mysqlrouter/mysqlrouter.conf, is not loaded because --config was used.

Each loaded configuration file overrides configuration settings from the previously read configuration files.

Default Configuration File Locations (Linux)

The following lists default file location for the router to read configuration files on popular Linux platforms.


Execute mysqlrouter --help to see the default configuration file locations (and their availability) on your system.

  • Default system-wide installation under /usr/local : /usr/local/etc/mysqlrouter.conf

  • RPM and Debian : /etc/mysqlrouter/mysqlrouter.conf

  • On all systems, a bootstrapped standalone installation using --directory adds mysqlrouter.conf into the directory defined by --directory.

User Comments
Sign Up Login You must be logged in to post a comment.