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 can be found in the
router
directory inside the MySQL Server
source code repository.
Get Source Code
To compile MySQL Router, download the MySQL Server source code from https://dev.mysql.com/downloads/mysql. Alternatively, git clone mysql-server on GitHub.
Download and unpack the MySQL Server source files, for example:
$> tar xzf mysql-8.4.3.tar.gz
$> cd mysql-8.4.3
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, 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 to
reference a newer bison executable:
$> cmake .. -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
Compile
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_
Installation
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 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 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 recommendedTo avoid building unit tests, also configure with
-DWITH_UNIT_TESTS=0