Documentation Home
MySQL Router 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb


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, seeInstalling MySQL from Source for specific prerequisites and additional details.

Note

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.44

Once 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.

Note

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/bison

Compile

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_all

Optionally 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 withoutmake install, configure Router to find the newly builtplugin_folder as compiling generates a non-standard installation directory structure. Either manually edit the generatedmysqlrouter.conf or set it during bootstrap, for example with:--conf-set-option=DEFAULT.plugin_folder=../plugin_output_directory

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

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

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