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
directory inside the MySQL Server source code repository.
Download and unpack the MySQL Server source files, for example:
$> tar xzf mysql-8.0.29.tar.gz $> cd mysql-8.0.29
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
before executing the
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 ..
cmake may yield errors related to
missing libraries. For example, on macOS it may need specific
boost and OpenSSL options:
$> cmake .. \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/tmp \ -DOPENSSL_ROOT_DIRemail@example.com \ -DOPENSSL_LIBRARIESfirstname.lastname@example.org/lib
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
make install initiates a full
MySQL Server build.
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_folderas compiling generates a non-standard installation directory structure. Either manually edit the generated
mysqlrouter.confor set it during bootstrap, for example with:
Similarly, also set
runtime_folderaccordingly, for example:
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