MySQL Router 8.0  /  Installing MySQL Router  /  Installing MySQL Router from Source Code

2.5 Installing MySQL Router from Source Code

MySQL Router is part of the MySQL Server source code tree; compiling MySQL Server also compiles MySQL Router. This assumes -DWITH_ROUTER=ON, which is enabled by default. The instructions here are brief, see Installing MySQL from Source for specific prerequisites and additional details.


MySQL Router source code was separate from MySQL Server before v8.0.13. It now resides within the router directory inside the MySQL Server source code repository.

Get Source Code

To compile MySQL Router, download the MySQL Server source code from Alternatively, git clone mysql-server on GitHub.

Download and unpack the MySQL Server source files, for example:

$> tar xzf mysql-8.0.38.tar.gz
$> cd mysql-8.0.38

Once this is complete, you need to configure using cmake as you would for MySQL Server.


The CMake program provides control over how you configure a source distribution. Typically, you do this using options on the CMake command line. The CMake options are not documented here, see MySQL Source-Configuration Options.

To compile the source code, create a folder to contain the compiled binaries and executables, run cmake to create the make file, and then compile the code. See Installing MySQL Server from Source for additional details, including platform specific prerequisites and concerns.


If you change anything and need to recompile from scratch, be sure to delete the CMakeCache.txt file before executing the cmake command.

Begin by executing the cmake command to create the make file. The following commands are run from the root of the MySQL Server source code tree:

$> mkdir build && cd build
$> cmake ..

Executing cmake may yield errors related to missing libraries or tools. For example, macOS builds may need custom boost and bison options:

$> cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/tmp -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison


You can compile MySQL Server as you normally would (simply make) as it also compiles MySQL Router, or build MySQL Router specific targets. For example, to only build MySQL Router with its libraries, plugins, and tests:

$> make mysqlrouter_all

Optionally execute the MySQL Router specific tests with ctest:

$> ctest -R routertest_


There is not a make option to only install MySQL Router from source because executing make install initiates a full MySQL Server build.

Developer Related Notes

Notes related to using and testing a locally compiled MySQL Router version for development purposes:

  • To run a local build without make install, configure Router to find the newly built plugin_folder as compiling generates a non-standard installation directory structure. Either manually edit the generated mysqlrouter.conf or set it during bootstrap, for example with: --conf-set-option=DEFAULT.plugin_folder=../plugin_output_directory

    Similarly, also set runtime_folder accordingly, for example: --conf-set-option=DEFAULT.runtime_folder=../runtime_output_directory

  • While individual targets do produce binaries, such as make mysqlrouter_password, building all Router targets is recommended

  • To avoid building unit tests, also configure with -DWITH_UNIT_TESTS=0