Chapter 4 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:

shell> cmake . -LH
shell> ccmake .

You can also affect CMake using certain environment variables. See Environment Variables.

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.

Table 4.1 MySQL Source-Configuration Option Reference (CMake)

FormatsDescriptionDefaultIntroducedRemoved
BUILD_CONFIGUse same build options as official releases   
CMAKE_BUILD_TYPEType of build to produceRelWithDebInfo  
CMAKE_CXX_FLAGSFlags for C++ Compiler   
CMAKE_C_FLAGSFlags for C Compiler   
CMAKE_INSTALL_PREFIXInstallation base directory/usr/local/mysql  
COMPILATION_COMMENTComment about compilation environment   
CPACK_MONOLITHIC_INSTALLWhether package build produces single fileOFF  
DEFAULT_CHARSETThe default server character setlatin1  
DEFAULT_COLLATIONThe default server collationlatin1_swedish_ci  
DISABLE_PSI_CONDExclude Performance Schema condition instrumentationOFF5.7.3 
DISABLE_PSI_FILEExclude Performance Schema file instrumentationOFF5.7.3 
DISABLE_PSI_IDLEExclude Performance Schema idle instrumentationOFF5.7.3 
DISABLE_PSI_MEMORYExclude Performance Schema memory instrumentationOFF5.7.3 
DISABLE_PSI_METADATAExclude Performance Schema metadata instrumentationOFF5.7.3 
DISABLE_PSI_MUTEXExclude Performance Schema mutex instrumentationOFF5.7.3 
DISABLE_PSI_RWLOCKExclude Performance Schema rwlock instrumentationOFF5.7.3 
DISABLE_PSI_SOCKETExclude Performance Schema socket instrumentationOFF5.7.3 
DISABLE_PSI_SPExclude Performance Schema stored program instrumentationOFF5.7.3 
DISABLE_PSI_STAGEExclude Performance Schema stage instrumentationOFF5.7.3 
DISABLE_PSI_STATEMENTExclude Performance Schema statement instrumentationOFF5.7.3 
DISABLE_PSI_STATEMENT_DIGESTExclude Performance Schema statement_digest instrumentationOFF5.7.3 
DISABLE_PSI_TABLEExclude Performance Schema table instrumentationOFF5.7.3 
DOWNLOAD_BOOSTWhether to download the Boost libraryOFF5.7.5 
DOWNLOAD_BOOST_TIMEOUTTimeout in seconds for downloading the Boost library6005.7.6 
-DWITH_PROTOBUFWhich Protocol Buffers package to usebundled5.7.12 
ENABLED_LOCAL_INFILEWhether to enable LOCAL for LOAD DATA INFILEOFF  
ENABLED_PROFILINGWhether to enable query profiling codeON  
ENABLE_DEBUG_SYNCWhether to enable Debug Sync supportON  
ENABLE_DOWNLOADSWhether to download optional filesOFF  
ENABLE_DTRACEWhether to include DTrace support   
ENABLE_GCOVWhether to include gcov support   
ENABLE_GPROFEnable gprof (optimized Linux builds only)OFF  
FORCE_UNSUPPORTED_COMPILERWhether to permit unsupported compilerOFF5.7.5 
IGNORE_AIO_CHECKWith -DBUILD_CONFIG=mysql_release, ignore libaio checkOFF  
INNODB_PAGE_ATOMIC_REF_COUNTEnable or disable atomic page reference countingON5.7.45.7.5
INSTALL_BINDIRUser executables directoryPREFIX/bin  
INSTALL_DOCDIRDocumentation directoryPREFIX/docs  
INSTALL_DOCREADMEDIRREADME file directoryPREFIX  
INSTALL_INCLUDEDIRHeader file directoryPREFIX/include  
INSTALL_INFODIRInfo file directoryPREFIX/docs  
INSTALL_LAYOUTSelect predefined installation layoutSTANDALONE  
INSTALL_LIBDIRLibrary file directoryPREFIX/lib  
INSTALL_MANDIRManual page directoryPREFIX/man  
INSTALL_MYSQLKEYRINGDIRDirectory for keyring_file plugin data fileplatform specific5.7.11 
INSTALL_MYSQLSHAREDIRShared data directoryPREFIX/share  
INSTALL_MYSQLTESTDIRmysql-test directoryPREFIX/mysql-test  
INSTALL_PKGCONFIGDIRDirectory for mysqlclient.pc pkg-config fileINSTALL_LIBDIR/pkgconfig5.7.9 
INSTALL_PLUGINDIRPlugin directoryPREFIX/lib/plugin  
INSTALL_SBINDIRServer executable directoryPREFIX/bin  
INSTALL_SCRIPTDIRScripts directoryPREFIX/scripts  
INSTALL_SECURE_FILE_PRIVDIRsecure_file_priv default valueplatform specific5.7.6 
INSTALL_SECURE_FILE_PRIV_EMBEDDEDDIRsecure_file_priv default value for libmysqld 5.7.8 
INSTALL_SHAREDIRaclocal/mysql.m4 installation directoryPREFIX/share  
INSTALL_SQLBENCHDIRsql-bench directoryPREFIX 5.7.8
INSTALL_SUPPORTFILESDIRExtra support files directoryPREFIX/support-files  
MAX_INDEXESMaximum indexes per table645.7.1 
MUTEX_TYPEInnoDB mutex typeevent5.7.2 
MYSQL_DATADIRData directory   
MYSQL_MAINTAINER_MODEWhether to enable MySQL maintainer-specific development environmentOFF  
MYSQL_PROJECT_NAMEWindows/OS X project name3306  
MYSQL_TCP_PORTTCP/IP port number3306  
MYSQL_UNIX_ADDRUnix socket file/tmp/mysql.sock  
ODBC_INCLUDESODBC includes directory   
ODBC_LIB_DIRODBC library directory   
OPTIMIZER_TRACEWhether to support optimizer tracing   
SUNPRO_CXX_LIBRARYClient link library on Solaris 10+ 5.7.5 
SYSCONFDIROption file directory   
SYSTEMD_PID_DIRDirectory for PID file under systemd/var/run/mysqld5.7.6 
SYSTEMD_SERVICE_NAMEName of MySQL service under systemdmysqld5.7.6 
TMPDIRtmpdir default value 5.7.4 
WIN_DEBUG_NO_INLINEWhether to disable function inliningOFF5.7.6 
WITHOUT_SERVERDo not build the serverOFF  
WITHOUT_xxx_STORAGE_ENGINEExclude storage engine xxx from build   
WITH_ASANEnable AddressSanitizerOFF5.7.3 
WITH_AUTHENTICATION_PAMBuild PAM authentication pluginOFF  
WITH_BOOSTThe location of the Boost library sources 5.7.5 
WITH_CLIENT_PROTOCOL_TRACINGBuild client-side protocol tracing frameworkON5.7.2 
WITH_DEBUGWhether to include debugging supportOFF  
WITH_DEFAULT_COMPILER_OPTIONSWhether to use default compiler optionsON  
WITH_DEFAULT_FEATURE_SETWhether to use default feature setON  
WITH_EDITLINEWhich libedit/editline library to usebundled5.7.2 
WITH_EMBEDDED_SERVERWhether to build embedded serverOFF  
WITH_EMBEDDED_SHARED_LIBRARYWhether to build a shared embedded server libraryOFF5.7.4 
WITH_EXTRA_CHARSETSWhich extra character sets to includeall  
WITH_INNODB_EXTRA_DEBUGWhether to include extra debugging support for InnoDB.OFF5.7.2 
WITH_INNODB_MEMCACHEDWhether to generate memcached shared libraries.OFF  
WITH_KEYRING_TESTBuild the keyring test programOFF5.7.11 
WITH_LIBEVENTWhich libevent library to usebundled  
WITH_LIBWRAPWhether to include libwrap (TCP wrappers) supportOFF  
WITH_MECABCompiles MeCab 5.7.6 
WITH_MSANEnable MemorySanitizerOFF5.7.4 
WITH_MSCRT_DEBUGEnable Visual Studio CRT memory leak tracingOFF5.7.6 
WITH_NDBCLUSTERBuild the NDB storage engine; alias for WITH_NDBCLUSTER_STORAGE_ENGINEON  
WITH_NDBCLUSTER_STORAGE_ENGINEBuild the NDB storage engineON  
WITH_RAPIDWhether to build rapid development cycle pluginsON5.7.12 
WITH_SSLType of SSL supportbundled  
WITH_SYSTEMDEnable installation of systemd support filesOFF5.7.6 
WITH_TEST_TRACE_PLUGINBuild test protocol trace pluginOFF5.7.2 
WITH_UBSANEnable Undefined Behavior SanitizerOFF5.7.6 
WITH_UNIXODBCEnable unixODBC supportOFF  
WITH_VALGRINDWhether to compile in Valgrind header filesOFF  
WITH_ZLIBType of zlib supportbundled  
WITH_xxx_STORAGE_ENGINECompile storage engine xxx statically into server   

The following sections provide more information about CMake options.

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 mysqld. Where applicable, configuration option descriptions indicate the corresponding mysqld startup option.

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 INSTALL PLUGIN statement or the --plugin-load option before it can be used). Some plugins might not support static or dynamic building.

The MyISAM, MERGE, MEMORY, and CSV 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, INNOBASE (InnoDB), NDB or NDBCLUSTER (NDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema). Examples:

-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
Note

WITH_NDBCLUSTER_STORAGE_ENGINE is supported only when building MySQL Cluster using the MySQL Cluster sources. It cannot be used to enable clustering support in other MySQL source trees or distributions. In MySQL Cluster source distributions, it is enabled by default. See Building MySQL Cluster from Source on Linux, and Compiling and Installing MySQL Cluster from Source on Windows, for more information.

Note

As of MySQL 5.7.9, 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 the -DDISABLE_PSI_MUTEX=1 option.

As of MySQL 5.7.4, 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

Before MySQL 5.7.4, to exclude a storage engine from the build, use -DWITHOUT_engine_STORAGE_ENGINE=1. (That syntax also works in 5.7.4 or later, 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:

shell> mkdir bld
shell> cd bld
shell> 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:

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

CMake Options for Compiling MySQL Cluster

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