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, seeInstalling 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 therouter directory inside the MySQL Server source code repository.
Get Source Code
To compile MySQL Router, download the MySQL Server source code fromhttps://dev.mysql.com/downloads/mysql. Alternatively, git clonemysql-server on GitHub.
Download and unpack the MySQL Server source files, for example:
$> tar xzf mysql-8.0.44.tar.gz$> cd mysql-8.0.44Once this is complete, you need to configure using cmake as you would for MySQL Server.
Configure
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, seeMySQL 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. SeeInstalling 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 theCMakeCache.txt file before executing thecmake command.
Begin by executing thecmake 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 .. Executingcmake 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/bisonCompile
You can compile MySQL Server as you normally would (simplymake) 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_allOptionally execute the MySQL Router specific tests withctest:
$> ctest -R routertest_Installation
There is not a make option to only install MySQL Router from source because executingmake 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 builtplugin_folderas compiling generates a non-standard installation directory structure. Either manually edit the generatedmysqlrouter.confor set it during bootstrap, for example with:--conf-set-option=DEFAULT.plugin_folder=../plugin_output_directorySimilarly, also set
runtime_folderaccordingly, for example:--conf-set-option=DEFAULT.runtime_folder=../runtime_output_directoryWhile individual targets do produce binaries, such as
make mysqlrouter_password, building all Router targets is recommendedTo avoid building unit tests, also configure with
-DWITH_UNIT_TESTS=0