2.9.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 Section 2.12, “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 2.11 MySQL Source-Configuration Option Reference (CMake)

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  
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 5.6.3 
ENABLE_GPROFEnable gprof (optimized Linux builds only)OFF5.6.6 
IGNORE_AIO_CHECKWith -DBUILD_CONFIG=mysql_release, ignore libaio checkOFF5.6.1 
INNODB_PAGE_ATOMIC_REF_COUNTEnable or disable atomic page reference countingON5.6.16 
INSTALL_BINDIRUser executables directoryPREFIX/bin  
INSTALL_DOCDIRDocumentation directoryPREFIX/docs  
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_MYSQLSHAREDIRShared data directoryPREFIX/share  
INSTALL_MYSQLTESTDIRmysql-test directoryPREFIX/mysql-test  
INSTALL_PLUGINDIRPlugin directoryPREFIX/lib/plugin  
INSTALL_SBINDIRServer executable directoryPREFIX/bin  
INSTALL_SCRIPTDIRScripts directoryPREFIX/scripts  
INSTALL_SHAREDIRaclocal/mysql.m4 installation directoryPREFIX/share  
INSTALL_SUPPORTFILESDIRExtra support files directoryPREFIX/support-files  
MEMCACHED_HOMEPath to memcached[none]  
MYSQL_DATADIRData directory   
MYSQL_MAINTAINER_MODEWhether to enable MySQL maintainer-specific development environmentOFF  
MYSQL_PROJECT_NAMEWindows/OS X project name33065.6.5 
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 5.6.3 
SUNPRO_CXX_LIBRARYClient link library on Solaris 10+ 5.6.20 
SYSCONFDIROption file directory   
TMPDIRtmpdir default value 5.6.16 
WITHOUT_SERVERDo not build the serverOFF  
WITHOUT_xxx_STORAGE_ENGINEExclude storage engine xxx from build   
WITH_ASANEnable AddressSanitizerOFF5.6.15 
WITH_BUNDLED_LIBEVENTUse bundled libevent when building ndbmemcacheON  
WITH_BUNDLED_MEMCACHEDUse bundled memcached when building ndbmemcacheON  
WITH_CLASSPATHClasspath to use when building MySQL Cluster Connector for Java. Default is an empty string.  
WITH_DEBUGWhether to include debugging supportOFF  
WITH_DEFAULT_COMPILER_OPTIONSWhether to use default compiler optionsON5.6.6 
WITH_DEFAULT_FEATURE_SETWhether to use default feature setON5.6.6 
WITH_EDITLINEWhich libedit/editline library to usebundled5.6.12 
WITH_EMBEDDED_SERVERWhether to build embedded serverOFF  
WITH_EMBEDDED_SHARED_LIBRARYWhether to build a shared embedded server libraryOFF5.6.17 
WITH_ERROR_INSERTEnable error injection in the NDB storage engine. Should not be used for building binaries intended for production.OFF  
WITH_EXTRA_CHARSETSWhich extra character sets to includeall  
WITH_INNODB_MEMCACHEDWhether to generate memcached shared libraries.OFF  
WITH_LIBEDITUse bundled libedit libraryON 5.6.12
WITH_LIBEVENTWhich libevent library to usebundled5.6.6 
WITH_LIBWRAPWhether to include libwrap (TCP wrappers) supportOFF  
WITH_NDBMTDBuild multi-threaded data node.ON  
WITH_NDB_BINLOGEnable binary logging by default by mysqld.ON  
WITH_NDB_DEBUGProduce a debug build for testing or troubleshooting.OFF  
WITH_NDB_JAVAEnable building of Java and ClusterJ support. Enabled by default. Supported in MySQL Cluster only.ON  
WITH_NDB_PORTDefault port used by a management server built with this option. If this option was not used to build it, the management server's default port is 1186.[none]  
WITH_NDB_TESTInclude NDB API test programs.OFF  
WITH_READLINEUse bundled readline libraryOFF 5.6.5
WITH_SSLType of SSL supportbundled  
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:


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 Section, “Building MySQL Cluster from Source on Linux”, and Section, “Compiling and Installing MySQL Cluster from Source on Windows”, for more information.

To exclude a storage engine from the build, use -DWITHOUT_engine_STORAGE_ENGINE=1. Examples:


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 \

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" \

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.