2.8 Installing MySQL from Source

Building MySQL from the source code enables you to customize build parameters, compiler optimizations, and installation location. For a list of systems on which MySQL is known to run, see https://www.mysql.com/support/supportedplatforms/database.html.

Before you proceed with an installation from source, check whether Oracle produces a precompiled binary distribution for your platform and whether it works for you. We put a great deal of effort into ensuring that our binaries are built with the best possible options for optimal performance. Instructions for installing binary distributions are available in *note binary-installation::.

If you are interested in building MySQL from a source distribution using build options the same as or similar to those use by Oracle to produce binary distributions on your platform, obtain a binary distribution, unpack it, and look in the 'docs/INFO_BIN' file, which contains information about how that MySQL distribution was configured and compiled.

Warning:

Building MySQL with nonstandard options may lead to reduced functionality, performance, or security.

 File: manual.info.tmp, Node: source-installation-methods, Next: source-installation-prerequisites, Prev: source-installation, Up: source-installation

2.8.1 Source Installation Methods

There are two methods for installing MySQL from source:

 File: manual.info.tmp, Node: source-installation-prerequisites, Next: source-installation-layout, Prev: source-installation-methods, Up: source-installation

2.8.2 Source Installation Prerequisites

Installation of MySQL from source requires several development tools. Some of these tools are needed no matter whether you use a standard source distribution or a development source tree. Other tool requirements depend on which installation method you use.

To install MySQL from source, the following system requirements must be satisfied, regardless of installation method:

To install MySQL from a standard source distribution, one of the following tools is required to unpack the distribution file:

To install MySQL from a development source tree, the following additional tools are required:

Note:

If you have to install any programs, modify your 'PATH' environment variable to include any directories in which the programs are located. See *note setting-environment-variables::.

If you run into problems and need to file a bug report, please use the instructions in *note bug-reports::.

 File: manual.info.tmp, Node: source-installation-layout, Next: installing-source-distribution, Prev: source-installation-prerequisites, Up: source-installation

2.8.3 MySQL Layout for Source Installation

By default, when you install MySQL after compiling it from source, the installation step installs files under '/usr/local/mysql'. The component locations under the installation directory are the same as for binary distributions. See note binary-installation-layout::, and note windows-installation-layout::. To configure installation locations different from the defaults, use the options described at *note source-configuration-options::.

 File: manual.info.tmp, Node: installing-source-distribution, Next: installing-development-tree, Prev: source-installation-layout, Up: source-installation

2.8.4 Installing MySQL Using a Standard Source Distribution

To install MySQL from a standard source distribution:

  1. Verify that your system satisfies the tool requirements listed at *note source-installation-prerequisites::.

  2. Obtain a distribution file using the instructions in *note getting-mysql::.

  3. Configure, build, and install the distribution using the instructions in this section.

  4. Perform postinstallation procedures using the instructions in *note postinstallation::.

MySQL uses 'CMake' as the build framework on all platforms. The instructions given here should enable you to produce a working installation. For additional information on using 'CMake' to build MySQL, see How to Build MySQL Server with CMake (https://dev.mysql.com/doc/internals/en/cmake.html).

If you start from a source RPM, use the following command to make a binary RPM that you can install. If you do not have 'rpmbuild', use 'rpm' instead.

 $> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

The result is one or more binary RPM packages that you install as indicated in *note linux-installation-rpm::.

The sequence for installation from a compressed 'tar' file or Zip archive source distribution is similar to the process for installing from a generic binary distribution (see *note binary-installation::), except that it is used on all platforms and includes steps to configure and compile the distribution. For example, with a compressed 'tar' file source distribution on Unix, the basic installation command sequence looks like this:

 # Preconfiguration setup
 $> groupadd mysql
 $> useradd -r -g mysql -s /bin/false mysql
 # Beginning of source-build specific instructions
 $> tar zxvf mysql-VERSION.tar.gz
 $> cd mysql-VERSION
 $> mkdir bld
 $> cd bld
 $> cmake ..
 $> make
 $> make install
 # End of source-build specific instructions
 # Postinstallation setup
 $> cd /usr/local/mysql
 $> mkdir mysql-files
 $> chown mysql:mysql mysql-files
 $> chmod 750 mysql-files
 $> bin/mysqld --initialize --user=mysql
 $> bin/mysql_ssl_rsa_setup
 $> bin/mysqld_safe --user=mysql &
 # Next command is optional
 $> cp support-files/mysql.server /etc/init.d/mysql.server

A more detailed version of the source-build specific instructions is shown following.

Note:

The procedure shown here does not set up any passwords for MySQL accounts. After following the procedure, proceed to *note postinstallation::, for postinstallation setup and testing.

Perform Preconfiguration Setup

On Unix, set up the 'mysql' user that owns the database directory and that should be used to run and execute the MySQL server, and the group to which this user belongs. For details, see *note binary-installation-createsysuser::. Then perform the following steps as the 'mysql' user, except as noted.

Obtain and Unpack the Distribution

Pick the directory under which you want to unpack the distribution and change location into it.

Obtain a distribution file using the instructions in *note getting-mysql::.

Unpack the distribution into the current directory:

Unpacking the distribution file creates a directory named 'mysql-VERSION'.

Configure the Distribution

Change location into the top-level directory of the unpacked distribution:

 $> cd mysql-VERSION

Build outside of the source tree to keep the tree clean. If the top-level source directory is named 'mysql-src' under your current working directory, you can build in a directory named 'build' at the same level. Create the directory and go there:

 $> mkdir bld
 $> cd bld

Configure the build directory. The minimum configuration command includes no options to override configuration defaults:

 $> cmake ../mysql-src

The build directory need not be outside the source tree. For example, you can build in a directory named 'build' under the top-level source tree. To do this, starting with 'mysql-src' as your current working directory, create the directory 'build' and then go there:

 $> mkdir build
 $> cd build

Configure the build directory. The minimum configuration command includes no options to override configuration defaults:

 $> cmake ..

If you have multiple source trees at the same level (for example, to build multiple versions of MySQL), the second strategy can be advantageous. The first strategy places all build directories at the same level, which requires that you choose a unique name for each. With the second strategy, you can use the same name for the build directory within each source tree. The following instructions assume this second strategy.

On Windows, specify the development environment. For example, the following commands configure MySQL for 32-bit or 64-bit builds, respectively:

 $> cmake .. -G "Visual Studio 12 2013"

 $> cmake .. -G "Visual Studio 12 2013 Win64"

On macOS, to use the Xcode IDE:

 $> cmake .. -G Xcode

When you run 'Cmake', you might want to add options to the command line. Here are some examples:

For a more extensive list of options, see *note source-configuration-options::.

To list the configuration options, use one of the following commands:

 $> cmake .. -L   # overview

 $> cmake .. -LH  # overview with help text

 $> cmake .. -LAH # all params with help text

 $> ccmake ..     # interactive display

If 'CMake' fails, you might need to reconfigure by running it again with different options. If you do reconfigure, take note of the following:

To prevent old object files or configuration information from being used, run these commands in the build directory on Unix before re-running 'CMake':

 $> make clean
 $> rm CMakeCache.txt

Or, on Windows:

 $> devenv MySQL.sln /clean
 $> del CMakeCache.txt

Before asking on the MySQL Community Slack (https://mysqlcommunity.slack.com/), check the files in the 'CMakeFiles' directory for useful information about the failure. To file a bug report, please use the instructions in *note bug-reports::.

Build the Distribution

On Unix:

 $> make
 $> make VERBOSE=1

The second command sets 'VERBOSE' to show the commands for each compiled source.

Use 'gmake' instead on systems where you are using GNU 'make' and it has been installed as 'gmake'.

On Windows:

 $> devenv MySQL.sln /build RelWithDebInfo

If you have gotten to the compilation stage, but the distribution does not build, see note compilation-problems::, for help. If that does not solve the problem, please enter it into our bugs database using the instructions given in note bug-reports::. If you have installed the latest versions of the required tools, and they crash trying to process our configuration files, please report that also. However, if you get a 'command not found' error or a similar problem for required tools, do not report it. Instead, make sure that all the required tools are installed and that your 'PATH' variable is set correctly so that your shell can find them.

Install the Distribution

On Unix:

 $> make install

This installs the files under the configured installation directory (by default, '/usr/local/mysql'). You might need to run the command as 'root'.

To install in a specific directory, add a 'DESTDIR' parameter to the command line:

 $> make install DESTDIR="/opt/mysql"

Alternatively, generate installation package files that you can install where you like:

 $> make package

This operation produces one or more '.tar.gz' files that can be installed like generic binary distribution packages. See *note binary-installation::. If you run 'CMake' with '-DCPACK_MONOLITHIC_INSTALL=1', the operation produces a single file. Otherwise, it produces multiple files.

On Windows, generate the data directory, then create a '.zip' archive installation package:

 $> devenv MySQL.sln /build RelWithDebInfo /project initial_database
 $> devenv MySQL.sln /build RelWithDebInfo /project package

You can install the resulting '.zip' archive where you like. See *note windows-install-archive::.

Perform Postinstallation Setup

The remainder of the installation process involves setting up the configuration file, creating the core databases, and starting the MySQL server. For instructions, see *note postinstallation::.

Note:

The accounts that are listed in the MySQL grant tables initially have no passwords. After starting the server, you should set up passwords for them using the instructions in *note postinstallation::.

 File: manual.info.tmp, Node: installing-development-tree, Next: source-ssl-library-configuration, Prev: installing-source-distribution, Up: source-installation

2.8.5 Installing MySQL Using a Development Source Tree

This section describes how to install MySQL from the latest development source code, which is hosted on GitHub (https://github.com/). To obtain the MySQL Server source code from this repository hosting service, you can set up a local MySQL Git repository.

On GitHub (https://github.com/), MySQL Server and other MySQL projects are found on the MySQL (https://github.com/mysql) page. The MySQL Server project is a single repository that contains branches for several MySQL series.

Prerequisites for Installing from Development Source

To install MySQL from a development source tree, your system must satisfy the tool requirements listed at *note source-installation-prerequisites::.

Setting Up a MySQL Git Repository

To set up a MySQL Git repository on your machine:

  1. Clone the MySQL Git repository to your machine. The following command clones the MySQL Git repository to a directory named 'mysql-server'. The initial download may take some time to complete, depending on the speed of your connection.

      $> git clone https://github.com/mysql/mysql-server.git
      Cloning into 'mysql-server'...
      remote: Counting objects: 1198513, done.
      remote: Total 1198513 (delta 0), reused 0 (delta 0), pack-reused 1198513
      Receiving objects: 100% (1198513/1198513), 1.01 GiB | 7.44 MiB/s, done.
      Resolving deltas: 100% (993200/993200), done.
      Checking connectivity... done.
      Checking out files: 100% (25510/25510), done.
  2. When the clone operation completes, the contents of your local MySQL Git repository appear similar to the following:

      ~> cd mysql-server
      ~/mysql-server> ls
      client             extra                mysys              storage
      cmake              include              packaging          strings
      CMakeLists.txt     INSTALL              plugin             support-files
      components         libbinlogevents      README             testclients
      config.h.cmake     libchangestreams     router             unittest
      configure.cmake    libmysql             run_doxygen.cmake  utilities
      Docs               libservices          scripts            VERSION
      Doxyfile-ignored   LICENSE              share              vio
      Doxyfile.in        man                  sql                win
      doxygen_resources  mysql-test           sql-common
  3. Use the 'git branch -r' command to view the remote tracking branches for the MySQL repository.

      ~/mysql-server> git branch -r
        origin/5.7
        origin/8.0
        origin/HEAD -> origin/trunk
        origin/cluster-7.4
        origin/cluster-7.5
        origin/cluster-7.6
        origin/trunk
  4. To view the branch that is checked out in your local repository, issue the 'git branch' command. When you clone the MySQL Git repository, the latest MySQL branch is checked out automatically. The asterisk identifies the active branch.

      ~/mysql-server$ git branch
      * trunk
  5. To check out an earlier MySQL branch, run the 'git checkout' command, specifying the branch name. For example, to check out the MySQL 5.7 branch:

      ~/mysql-server$ git checkout 5.7
      Checking out files: 100% (9600/9600), done.
      Branch 5.7 set up to track remote branch 5.7 from origin.
      Switched to a new branch '5.7'
  6. To obtain changes made after your initial setup of the MySQL Git repository, switch to the branch you want to update and issue the 'git pull' command:

      ~/mysql-server$ git checkout 8.0
      ~/mysql-server$ git pull

    To examine the commit history, use the 'git log' command:

      ~/mysql-server$ git log

    You can also browse commit history and source code on the GitHub MySQL (https://github.com/mysql) site.

    If you see changes or code that you have a question about, ask on MySQL Community Slack (https://mysqlcommunity.slack.com/).

  7. After you have cloned the MySQL Git repository and have checked out the branch you want to build, you can build MySQL Server from the source code. Instructions are provided in *note installing-source-distribution::, except that you skip the part about obtaining and unpacking the distribution.

    Be careful about installing a build from a distribution source tree on a production machine. The installation command may overwrite your live release installation. If you already have MySQL installed and do not want to overwrite it, run 'CMake' with values for the 'CMAKE_INSTALL_PREFIX', 'MYSQL_TCP_PORT', and 'MYSQL_UNIX_ADDR' options different from those used by your production server. For additional information about preventing multiple servers from interfering with each other, see *note multiple-servers::.

    Play hard with your new installation. For example, try to make new features crash. Start by running 'make test'. See The MySQL Test Suite (https://dev.mysql.com/doc/extending-mysql/5.7/en/mysql-test-suite.html).

 File: manual.info.tmp, Node: source-ssl-library-configuration, Next: source-configuration-options, Prev: installing-development-tree, Up: source-installation

2.8.6 Configuring SSL Library Support

An SSL library is required for support of encrypted connections, entropy for random number generation, and other encryption-related operations. Your system must support either OpenSSL or yaSSL:

If you compile MySQL from a source distribution, 'CMake' configures the distribution to use the installed OpenSSL library by default.

To compile using OpenSSL, use this procedure:

  1. Ensure that OpenSSL 1.0.1 or newer is installed on your system. If the installed OpenSSL version is older than 1.0.1, 'CMake' produces an error at MySQL configuration time. If it is necessary to obtain OpenSSL, visit http://www.openssl.org.

  2. The 'WITH_SSL' 'CMake' option determines which SSL library to use for compiling MySQL (see *note source-configuration-options::). The default is '-DWITH_SSL=system', which uses OpenSSL. To make this explicit, specify that option. For example:

      cmake . -DWITH_SSL=system

    That command configures the distribution to use the installed OpenSSL library. Alternatively, to explicitly specify the path name to the OpenSSL installation, use the following syntax. This can be useful if you have multiple versions of OpenSSL installed, to prevent 'CMake' from choosing the wrong one:

      cmake . -DWITH_SSL=PATH_NAME
  3. Compile and install the distribution.

To check whether a *note 'mysqld': mysqld. server supports encrypted connections, examine the value of the 'have_ssl' system variable:

 mysql> SHOW VARIABLES LIKE 'have_ssl';
 +---------------+-------+
 | Variable_name | Value |
 +---------------+-------+
 | have_ssl      | YES   |
 +---------------+-------+

If the value is 'YES', the server supports encrypted connections. If the value is 'DISABLED', the server is capable of supporting encrypted connections but was not started with the appropriate '--ssl-XXX' options to enable encrypted connections to be used; see *note using-encrypted-connections::.

To determine whether a server was compiled using OpenSSL or yaSSL, check the existence of any of the system or status variables that are present only for OpenSSL. See *note ssl-libraries::.

 File: manual.info.tmp, Node: source-configuration-options, Next: compilation-problems, Prev: source-ssl-library-configuration, Up: source-installation

2.8.7 MySQL Source-Configuration Options

The 'CMake' program provides a great deal of control over how you configure a MySQL source distribution. Typically, you do this using options on the 'CMake' command line. For information about options supported by 'CMake', run either of these commands in the top-level source directory:

 $> cmake . -LH

 $> ccmake .

You can also affect 'CMake' using certain environment variables. See *note environment-variables::.

For boolean options, the value may be specified as '1' or 'ON' to enable the option, or as '0' or 'OFF' to disable the option.

Many options configure compile-time defaults that can be overridden at server startup. For example, the 'CMAKE_INSTALL_PREFIX', 'MYSQL_TCP_PORT', and 'MYSQL_UNIX_ADDR' options that configure the default installation base directory location, TCP/IP port number, and Unix socket file can be changed at server startup with the '--basedir', '--port', and '--socket' options for note 'mysqld': mysqld. Where applicable, configuration option descriptions indicate the corresponding note 'mysqld': mysqld. startup option.

The following sections provide more information about 'CMake' options.

CMake Option Reference

The following table shows the available 'CMake' options. In the 'Default' column, 'PREFIX' stands for the value of the 'CMAKE_INSTALL_PREFIX' option, which specifies the installation base directory. This value is used as the parent location for several of the installation subdirectories.

MySQL Source-Configuration Option Reference (CMake)

Formats Description Default IntroducedRemoved

'BUILD_CONFIG'

Use same build options as official releases

'CMAKE_BUILD_TYPE'

Type of build to 'RelWithDebInfo' produce

'CMAKE_CXX_FLAGS'

Flags for C++ Compiler

'CMAKE_C_FLAGS'

Flags for C Compiler

'CMAKE_INSTALL_PREFIX'

Installation base '/usr/local/mysql' directory

'COMPILATION_COMMENT'

Comment about compilation environment

'CPACK_MONOLITHIC_INSTALL'

Whether package 'OFF' build produces
single file

'DEFAULT_CHARSET'

The default server 'latin1' character set

'DEFAULT_COLLATION'

The default server 'latin1_swedish_ci' collation

'DISABLE_PSI_COND'

Exclude Performance 'OFF' Schema condition
instrumentation

'DISABLE_PSI_FILE'

Exclude Performance 'OFF' Schema file
instrumentation

'DISABLE_PSI_IDLE'

Exclude Performance 'OFF' Schema idle
instrumentation

'DISABLE_PSI_MEMORY'

Exclude Performance 'OFF' Schema memory
instrumentation

'DISABLE_PSI_METADATA'

Exclude Performance 'OFF' Schema metadata
instrumentation

'DISABLE_PSI_MUTEX'

Exclude Performance 'OFF' Schema mutex
instrumentation

'DISABLE_PSI_PS'

Exclude the 'OFF' performance schema
prepared statements

'DISABLE_PSI_RWLOCK'

Exclude Performance 'OFF' Schema rwlock
instrumentation

'DISABLE_PSI_SOCKET'

Exclude Performance 'OFF' Schema socket
instrumentation

'DISABLE_PSI_SP'

Exclude Performance 'OFF' Schema stored
program instrumentation

'DISABLE_PSI_STAGE'

Exclude Performance 'OFF' Schema stage
instrumentation

'DISABLE_PSI_STATEMENT'

Exclude Performance 'OFF' Schema statement
instrumentation

'DISABLE_PSI_STATEMENT_DIGEST'

Exclude Performance 'OFF' Schema
statements_digest instrumentation

'DISABLE_PSI_TABLE'

Exclude Performance 'OFF' Schema table
instrumentation

'DISABLE_PSI_THREAD'

Exclude the 'OFF' performance schema
thread instrumentation

'DISABLE_PSI_TRANSACTION'

Exclude the 'OFF' performance schema
transaction instrumentation

'DOWNLOAD_BOOST'

Whether to download 'OFF' the Boost library

'DOWNLOAD_BOOST_TIMEOUT'

Timeout in seconds '600' for downloading the
Boost library

'ENABLED_LOCAL_INFILE'

Whether to enable 'OFF' LOCAL for LOAD DATA

'ENABLED_PROFILING'

Whether to enable 'ON' query profiling code

'ENABLE_DOWNLOADS'

Whether to download 'OFF' optional files

'ENABLE_DTRACE'

Whether to include DTrace support

'ENABLE_GCOV'

Whether to include gcov support

'ENABLE_GPROF'

Enable gprof 'OFF' (optimized Linux
builds only)

'FORCE_UNSUPPORTED_COMPILER'

Whether to permit 'OFF' unsupported
compilers

'IGNORE_AIO_CHECK'

With 'OFF' -DBUILD_CONFIG=mysql_release, ignore libaio check

'INSTALL_BINDIR'

User executables 'PREFIX/bin' directory

'INSTALL_DOCDIR'

Documentation 'PREFIX/docs' directory

'INSTALL_DOCREADMEDIR'

README file 'PREFIX' directory

'INSTALL_INCLUDEDIR'

Header file 'PREFIX/include' directory

'INSTALL_INFODIR'

Info file directory 'PREFIX/docs'

'INSTALL_LAYOUT'

Select predefined 'STANDALONE' installation layout

'INSTALL_LIBDIR'

Library file 'PREFIX/lib' directory

'INSTALL_MANDIR'

Manual page 'PREFIX/man' directory

'INSTALL_MYSQLKEYRINGDIR'

Directory for 'platform specific' 5.7.11 keyring_file plugin
data file

'INSTALL_MYSQLSHAREDIR'

Shared data 'PREFIX/share' directory

'INSTALL_MYSQLTESTDIR'

mysql-test directory 'PREFIX/mysql-test'

'INSTALL_PKGCONFIGDIR'

Directory for 'INSTALL_LIBDIR/pkgconfig' mysqlclient.pc
pkg-config file

'INSTALL_PLUGINDIR'

Plugin directory 'PREFIX/lib/plugin'

'INSTALL_SBINDIR'

Server executable 'PREFIX/bin' directory

'INSTALL_SCRIPTDIR'

Scripts directory 'PREFIX/scripts'

'INSTALL_SECURE_FILE_PRIVDIR'

secure_file_priv 'platform specific' default value

'INSTALL_SECURE_FILE_PRIV_EMBEDDEDDIR'

secure_file_priv default value for libmysqld

'INSTALL_SHAREDIR'

aclocal/mysql.m4 'PREFIX/share' installation
directory

'INSTALL_SUPPORTFILESDIR'

Extra support files 'PREFIX/support-files' directory

'MAX_INDEXES'

Maximum indexes per '64' table

'MEMCACHED_HOME'

Path to memcached; '[none]' 5.7.33 obsolete

'MUTEX_TYPE'

InnoDB mutex type 'event'

'MYSQLX_TCP_PORT'

TCP/IP port number '33060' 5.7.17 used by X Plugin

'MYSQLX_UNIX_ADDR'

Unix socket file '/tmp/mysqlx.sock' 5.7.15 used by X Plugin

'MYSQL_DATADIR'

Data directory

'MYSQL_MAINTAINER_MODE'

Whether to enable 'OFF' MySQL
maintainer-specific development environment

'MYSQL_PROJECT_NAME'

Windows/macOS 'MySQL' project name

'MYSQL_TCP_PORT'

TCP/IP port number '3306'

'MYSQL_UNIX_ADDR'

Unix socket file '/tmp/mysql.sock'

'ODBC_INCLUDES'

ODBC includes directory

'ODBC_LIB_DIR'

ODBC library directory

'OPTIMIZER_TRACE'

Whether to support optimizer tracing

'REPRODUCIBLE_BUILD'

Take extra care to 5.7.19 create a build
result independent of build location and time

'SUNPRO_CXX_LIBRARY'

Client link library on Solaris 10+

'SYSCONFDIR'

Option file directory

'SYSTEMD_PID_DIR'

Directory for PID '/var/run/mysqld' file under systemd

'SYSTEMD_SERVICE_NAME'

Name of MySQL 'mysqld' service under
systemd

'TMPDIR'

tmpdir default value

'WIN_DEBUG_NO_INLINE'

Whether to disable 'OFF' function inlining

'WITHOUT_SERVER'

Do not build the 'OFF' server; internal use
only

'WITHOUT_xxx_STORAGE_ENGINE'

Exclude storage engine xxx from build

'WITH_ASAN'

Enable 'OFF' AddressSanitizer

'WITH_ASAN_SCOPE'

Enable 'OFF' 5.7.21 AddressSanitizer
-fsanitize-address-use-after-scope Clang flag

'WITH_AUTHENTICATION_LDAP'

Whether to report 'OFF' 5.7.19 error if LDAP
authentication plugins cannot be built

'WITH_AUTHENTICATION_PAM'

Build PAM 'OFF' authentication
plugin

'WITH_AWS_SDK'

Location of Amazon 5.7.19 Web Services
software development kit

'WITH_BOOST'

The location of the Boost library sources

'WITH_BUNDLED_LIBEVENT'

Use bundled libevent 'ON' 5.7.33 when building
ndbmemcache; obsolete

'WITH_BUNDLED_MEMCACHED'

Use bundled 'ON' 5.7.33 memcached when
building ndbmemcache; obsolete

'WITH_CLASSPATH'

Classpath to use '' when building MySQL
Cluster Connector for Java. Default is an empty string.

'WITH_CLIENT_PROTOCOL_TRACING'

Build client-side 'ON' protocol tracing
framework

'WITH_CURL'

Location of curl 5.7.19 library

'WITH_DEBUG'

Whether to include 'OFF' debugging support

'WITH_DEFAULT_COMPILER_OPTIONS'

Whether to use 'ON' default compiler
options

'WITH_DEFAULT_FEATURE_SET'

Whether to use 'ON' default feature set

'WITH_EDITLINE'

Which 'bundled' libedit/editline
library to use

'WITH_EMBEDDED_SERVER'

Whether to build 'OFF' embedded server

'WITH_EMBEDDED_SHARED_LIBRARY'

Whether to build a 'OFF' shared embedded
server library

'WITH_ERROR_INSERT'

Enable error 'OFF' injection in the NDB
storage engine. Should not be used for building binaries intended for production.

'WITH_EXTRA_CHARSETS'

Which extra 'all' character sets to
include

'WITH_GMOCK'

Path to googlemock distribution

'WITH_INNODB_EXTRA_DEBUG'

Whether to include 'OFF' extra debugging
support for InnoDB.

'WITH_INNODB_MEMCACHED'

Whether to generate 'OFF' memcached shared
libraries.

'WITH_KEYRING_TEST'

Build the keyring 'OFF' 5.7.11 test program

'WITH_LDAP'

Internal use only 5.7.29

'WITH_LIBEVENT'

Which libevent 'bundled' library to use

'WITH_LIBWRAP'

Whether to include 'OFF' libwrap (TCP
wrappers) support

'WITH_LZ4'

Type of LZ4 library 'bundled' 5.7.14 support

'WITH_MECAB'

Compiles MeCab

'WITH_MSAN'

Enable 'OFF' MemorySanitizer

'WITH_MSCRT_DEBUG'

Enable Visual Studio 'OFF' CRT memory leak
tracing

'WITH_NDBAPI_EXAMPLES'

Build API example 'OFF' programs.

'WITH_NDBCLUSTER'

NDB 8.0.30 and 'ON' earlier: Build NDB
storage engine. NDB 8.0.31 and later: Deprecated; use WITH_NDB instead

'WITH_NDBCLUSTER_STORAGE_ENGINE'

Prior to NDB 8.0.31, 'ON' this was for
internal use only. NDB 8.0.31 and later: toggles (only) inclusion of NDBCLUSTER storage engine

'WITH_NDBMTD'

Build multithreaded 'ON' data node binary

'WITH_NDB_BINLOG'

Enable binary 'ON' logging by default
by mysqld.

'WITH_NDB_DEBUG'

Produce a debug 'OFF' build for testing or
troubleshooting.

'WITH_NDB_JAVA'

Enable building of 'ON' Java and ClusterJ
support. Enabled by default. Supported in MySQL Cluster only.

'WITH_NDB_PORT'

Default port used by '[none]' a management server
built with this option. If this option was not used to build it, the management server's default port is 1186.

'WITH_NDB_TEST'

Include NDB API test 'OFF' programs.

'WITH_NUMA'

Set NUMA memory 5.7.17 allocation policy

'WITH_PROTOBUF'

Which Protocol 'bundled' 5.7.12 Buffers package to
use

'WITH_RAPID'

Whether to build 'ON' 5.7.12 rapid development
cycle plugins

'WITH_SASL'

Internal use only 5.7.29

'WITH_SSL'

Type of SSL support 'system'

'WITH_SYSTEMD'

Enable installation 'OFF' of systemd support
files

'WITH_TEST_TRACE_PLUGIN'

Build test protocol 'OFF' trace plugin

'WITH_UBSAN'

Enable Undefined 'OFF' Behavior Sanitizer

'WITH_UNIT_TESTS'

Compile MySQL with 'ON' unit tests

'WITH_UNIXODBC'

Enable unixODBC 'OFF' support

'WITH_VALGRIND'

Whether to compile 'OFF' in Valgrind header
files

'WITH_ZLIB'

Type of zlib support 'bundled'

'WITH_xxx_STORAGE_ENGINE'

Compile storage engine xxx statically into server

General Options

Installation Layout Options

The 'CMAKE_INSTALL_PREFIX' option indicates the base installation directory. Other options with names of the form 'INSTALL_XXX' that indicate component locations are interpreted relative to the prefix and their values are relative pathnames. Their values should not include the prefix.

Storage Engine Options

Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server) or a dynamic module (built as a dynamic library that must be installed into the server using the *note 'INSTALL PLUGIN': install-plugin. statement or the '--plugin-load' option before it can be used). Some plugins might not support static or dynamic building.

The note 'InnoDB': innodb-storage-engine, note 'MyISAM': myisam-storage-engine, note 'MERGE': merge-storage-engine, note 'MEMORY': memory-storage-engine, and *note 'CSV': csv-storage-engine. engines are mandatory (always compiled into the server) and need not be installed explicitly.

To compile a storage engine statically into the server, use '-DWITH_ENGINE_STORAGE_ENGINE=1'. Some permissible ENGINE values are 'ARCHIVE', 'BLACKHOLE', 'EXAMPLE', 'FEDERATED', and 'PARTITION' (partitioning support). Examples:

 -DWITH_ARCHIVE_STORAGE_ENGINE=1
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1

To build MySQL with support for NDB Cluster, use the 'WITH_NDBCLUSTER' option.

Note:

'WITH_NDBCLUSTER' is supported only when building NDB Cluster using the NDB Cluster sources. It cannot be used to enable clustering support in other MySQL source trees or distributions. In NDB Cluster source distributions, it is enabled by default. See note mysql-cluster-install-linux-source::, and note mysql-cluster-install-windows-source::, for more information.

Note:

It is not possible to compile without Performance Schema support. If it is desired to compile without particular types of instrumentation, that can be done with the following 'CMake' options:

 DISABLE_PSI_COND
 DISABLE_PSI_FILE
 DISABLE_PSI_IDLE
 DISABLE_PSI_MEMORY
 DISABLE_PSI_METADATA
 DISABLE_PSI_MUTEX
 DISABLE_PSI_PS
 DISABLE_PSI_RWLOCK
 DISABLE_PSI_SOCKET
 DISABLE_PSI_SP
 DISABLE_PSI_STAGE
 DISABLE_PSI_STATEMENT
 DISABLE_PSI_STATEMENT_DIGEST
 DISABLE_PSI_TABLE
 DISABLE_PSI_THREAD
 DISABLE_PSI_TRANSACTION

For example, to compile without mutex instrumentation, configure MySQL using '-DDISABLE_PSI_MUTEX=1'.

To exclude a storage engine from the build, use '-DWITH_ENGINE_STORAGE_ENGINE=0'. Examples:

 -DWITH_EXAMPLE_STORAGE_ENGINE=0
 -DWITH_FEDERATED_STORAGE_ENGINE=0
 -DWITH_PARTITION_STORAGE_ENGINE=0

It is also possible to exclude a storage engine from the build using '-DWITHOUT_ENGINE_STORAGE_ENGINE=1' (but '-DWITH_ENGINE_STORAGE_ENGINE=0' is preferred). Examples:

 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
 -DWITHOUT_PARTITION_STORAGE_ENGINE=1

If neither '-DWITH_ENGINE_STORAGE_ENGINE' nor '-DWITHOUT_ENGINE_STORAGE_ENGINE' are specified for a given storage engine, the engine is built as a shared module, or excluded if it cannot be built as a shared module.

Feature Options

Compiler Flags

To specify your own C and C++ compiler flags, for flags that do not affect optimization, use the 'CMAKE_C_FLAGS' and 'CMAKE_CXX_FLAGS' CMake options.

When providing your own compiler flags, you might want to specify 'CMAKE_BUILD_TYPE' as well.

For example, to create a 32-bit release build on a 64-bit Linux machine, do this:

 $> mkdir build
 $> cd build
 $> cmake .. -DCMAKE_C_FLAGS=-m32 \
   -DCMAKE_CXX_FLAGS=-m32 \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo

If you set flags that affect optimization ('-ONUMBER'), you must set the 'CMAKE_C_FLAGS_BUILD_TYPE' and/or 'CMAKE_CXX_FLAGS_BUILD_TYPE' options, where BUILD_TYPE corresponds to the 'CMAKE_BUILD_TYPE' value. To specify a different optimization for the default build type ('RelWithDebInfo') set the 'CMAKE_C_FLAGS_RELWITHDEBINFO' and 'CMAKE_CXX_FLAGS_RELWITHDEBINFO' options. For example, to compile on Linux with '-O3' and with debug symbols, do this:

 $> cmake .. -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3 -g" \
   -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g"

CMake Options for Compiling NDB Cluster

The following options are for use when building NDB Cluster with the NDB Cluster sources; they are not currently supported when using sources from the MySQL 5.7 Server tree.

 File: manual.info.tmp, Node: compilation-problems, Next: source-configuration-third-party, Prev: source-configuration-options, Up: source-installation

2.8.8 Dealing with Problems Compiling MySQL

The solution to many problems involves reconfiguring. If you do reconfigure, take note of the following:

To prevent old object files or configuration information from being used, run the following commands before re-running 'CMake':

On Unix:

 $> make clean
 $> rm CMakeCache.txt

On Windows:

 $> devenv MySQL.sln /clean
 $> del CMakeCache.txt

If you build outside of the source tree, remove and recreate your build directory before re-running 'CMake'. For instructions on building outside of the source tree, see How to Build MySQL Server with CMake (https://dev.mysql.com/doc/internals/en/cmake.html).

On some systems, warnings may occur due to differences in system include files. The following list describes other problems that have been found to occur most often when compiling MySQL:

For information about acquiring or updating tools, see the system requirements in *note source-installation::.

 File: manual.info.tmp, Node: source-configuration-third-party, Prev: compilation-problems, Up: source-installation

2.8.9 MySQL Configuration and Third-Party Tools

Third-party tools that need to determine the MySQL version from the MySQL source can read the 'VERSION' file in the top-level source directory. The file lists the pieces of the version separately. For example, if the version is MySQL 5.7.4-m14, the file looks like this:

 MYSQL_VERSION_MAJOR=5
 MYSQL_VERSION_MINOR=7
 MYSQL_VERSION_PATCH=4
 MYSQL_VERSION_EXTRA=-m14

If the source is not for a MySQL Server General Availablility (GA) release, the 'MYSQL_VERSION_EXTRA' value is nonempty. In the preceding example, the value corresponds to Milestone 14.

'MYSQL_VERSION_EXTRA' is also nonempty for NDB Cluster releases (including GA releases of NDB Cluster), as shown here:

 MYSQL_VERSION_MAJOR=5
 MYSQL_VERSION_MINOR=7
 MYSQL_VERSION_PATCH=32
 MYSQL_VERSION_EXTRA=-ndb-7.5.21

To construct a five-digit number from the version components, use this formula:

 MYSQL_VERSION_MAJOR*10000 + MYSQL_VERSION_MINOR*100 + MYSQL_VERSION_PATCH

 File: manual.info.tmp, Node: postinstallation, Next: upgrading, Prev: source-installation, Up: installing