Building MySQL 5.7

The 5.7.5 DMR is now available, and we’ve made some changes to our build system in this one, so I wanted to spend some time discussing how you would now build MySQL.

When we released our April labs release, I wrote about building MySQL with Boost. Now that the first GIS work using Boost.Geometry has passed all the hurdles and landed in a development milestone release (DMR), it’s time to revisit the topic. From now on (5.7.5 and newer), MySQL needs Boost headers to compile. It’s not optional.

We got a few bug reports on the build process for the labs release. Hartmut Holzgraefe quickly submitted bugs 72172, 72185, 72186 and 72188, which have all now been fixed. Thank you, Hartmut! It’s very encouraging for all of us working on this to get quality feedback on a labs release!

Getting Started

Assuming that you’ve just downloaded the 5.7.5 tarball:

This is almost exactly the same way we did it in the labs release. Actually, that CMake command line way still works, I’ve only changed $HOME to ~ to demonstrate that it now works. We now also support relative paths (bug 72185).

We’ve also improved the error messages if anything goes wrong (bug 72172).

This is the recommended way for developers to build MySQL. If you already have the correct Boost version installed in your include path (we only need the header files), you don’t need any CMake options at all.

After the first build, you can drop the build options on later CMake runs. CMake will remember your settings. However, it doesn’t hurt to always use them.

Advanced Build Options

There are two new build options: WITH_BOOST and DOWNLOAD_BOOST. I’ll describe both here, but if you really want to look at all the details and inner workings, have a look at cmake/boost.cmake in the source tree.


This specifies where CMake will find Boost. It can point to:

  • a tarball/zip file
  • a directory containing a tarball/zip file (it has to have the standard Boost tarball/zip file name)
  • a directory where the tarball/zip file was unpacked

You can specify both absolute and relative paths, and the tilde will be expanded. And of course, any path name expansion your shell does for you will work. There’s no default value. If you don’t specify anything, you’ll need to have Boost in you normal include path.

The WITH_BOOST build option can be set on the CMake command line like in the example above, or you can use the WITH_BOOST environment variable. Our CMake scripts will also recognize the BOOST_ROOT environment variable that is commonly used by projects using Boost as an alias for WITH_BOOST.

The order of precedence is (highest to lowest):

  1. WITH_BOOST option on the CMake command line
  2. WITH_BOOST environment variable
  3. BOOST_ROOT environment variable

If CMake can’t find Boost, it will fail with a friendly error message telling you how to use DOWNLOAD_BOOST.


This boolean option tells CMake to download the Boost tarball or zip file from Boost’s standard download location (currently Sourceforge). The default is DOWNLOAD_BOOST=0, which means don’t download. Set it to 1 to enable downloading.

In order to provide a stable code base, MySQL depends on a specific version of Boost. When we change our code to depend on a newer version of Boost, DOWNLOAD_BOOST=1 will make sure the new version will be automatically downloaded for you.

About Norvald H. Ryeng

Norvald has been at Oracle since 2011 and is the MySQL optimizer team lead, responsible for query optimization and execution. He holds a PhD in Computer and Information Science from the Norwegian University of Science and Technology.

7 thoughts on “Building MySQL 5.7

  1. Hi Norvald, thanks for posting the instructions about building the latest DMR. I think you are missing a “cd ..” after the “cmake …” and before the “make” though.

    1. In general, no. If you try it out of the box, it won’t compile, because the CMake script will halt and ask you to point it to Boost 1.59.0.

      If you tweak the CMake scripts to accept 1.60.0, it will compile, but, in the process, you will reintroduce some bugs (caught by various tests in the gis test suite).

      When we discover a bug in Boost, we fix it in the development branch of Boost. Since Boost.Geometry is a header only library, these fixes will be modifications to header files. At the same time we submit the bugfix to Boost upstream, we copy the modified header files into the MySQL source tree into a location that overrides header files in Boost. That way we can apply the fix to MySQL immediately, without waiting for a new Boost release.

      Since we apply bugfixes both to Boost and MySQL, the bug will be fixed immediately in MySQL and in the next Boost release. In the case of Boost 1.60.0, there’s at least one bug that is fixed in 5.7 that is not included in Boost 1.60.0. I believe this fix will be included in Boost 1.61.0.

      But by that time we may have fixed more bugs. Some fixes may be included in Boost 1.61.0, but others may have to wait for Boost 1.62.0. The same may happen when Boost 1.63.0 is released. So, in general, you can’t expect to compile MySQL with another Boost version than the specified one without reintroducing bugs.

  2. Hello,

    I am unable to find any post regarding building 5.6.x from source, I am trying to build MySQL 5.6.28 using Visual Studio 2015 on Windows 7 but it fails with lot of errors, can anybody help me in this regard, I have posted my query on MySQL Internals mailing list but have not received any reply.


Leave a Reply