8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

2.8.7 MySQL 源配置选项2.8.7 MySQL Source-Configuration Options

CMake 程序提供了对如何配置 MySQL 源分发的大量控制。通常,您可以使用 CMake 命令行上的选项来执行此操作。有关 CMake 支持的选项的信息,请在顶级源目录中运行以下命令之一: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 .

您还可以使用某些环境变量影响 CMake。请参阅第 6.9 节“环境变量”。You can also affect CMake using certain environment variables. See Section 6.9, “Environment Variables”.

对于布尔选项,可以将值指定为 1 或 ON 以启用该选项,或者指定为 0 或 OFF禁用该选项。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.

许多选项用于配置编译时的默认值,这些默认值可以在服务器启动时被覆盖。例如,CMAKE_INSTALL_PREFIX, MYSQL_TCP_PORT,以及MYSQL_UNIX_ADDR用于配置默认安装基础目录位置、TCP/IP 端口号和 Unix 套接字文件的选项可以在服务器启动时通过--basedir, --port,以及--socket选项进行更改。mysqld在适用情况下,配置选项描述会指明对应的mysqld启动选项。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.

以下部分提供有关 CMake 选项的更多信息。The following sections provide more information about CMake options.

CMake 选项参考CMake Option Reference

下表显示了可用的 CMake 选项。在 Default 列中,PREFIX 代表 CMAKE_INSTALL_PREFIX 选项的值,该选项指定安装基目录。该值用作多个安装子目录的父位置。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.

表 2.15 MySQL 源配置选项参考 (CMake)Table 2.15 MySQL Source-Configuration Option Reference (CMake)

格式Formats 说明Description 默认Default
ADD_GDB_INDEXADD_GDB_INDEX 是否启用在二进制文件中生成 .gdb_index 部分Whether to enable generation of .gdb_index section in binaries
BUILD_CONFIGBUILD_CONFIG 使用与正式版本相同的构建选项Use same build options as official releases
BUNDLE_RUNTIME_LIBRARIESBUNDLE_RUNTIME_LIBRARIES 将运行时库与适用于 Windows 的服务器 MSI 和 Zip 包捆绑在一起Bundle runtime libraries with server MSI and Zip packages for Windows OFFOFF
CMAKE_BUILD_TYPECMAKE_BUILD_TYPE 要生成的构建类型Type of build to produce RelWithDebInfoRelWithDebInfo
CMAKE_CXX_FLAGSCMAKE_CXX_FLAGS C++ 编译器的标志Flags for C++ Compiler
CMAKE_C_FLAGSCMAKE_C_FLAGS C 编译器的标志Flags for C Compiler
CMAKE_INSTALL_PREFIXCMAKE_INSTALL_PREFIX 安装基目录Installation base directory /usr/local/mysql/usr/local/mysql
COMPILATION_COMMENTCOMPILATION_COMMENT 编译环境注释Comment about compilation environment
COMPILATION_COMMENT_SERVERCOMPILATION_COMMENT_SERVER 有关 mysqld 使用的编译环境的注释Comment about compilation environment for use by mysqld
COMPRESS_DEBUG_SECTIONSCOMPRESS_DEBUG_SECTIONS 压缩二进制文件的调试部分可执行文件Compress debug sections of binary executables OFFOFF
CPACK_MONOLITHIC_INSTALLCPACK_MONOLITHIC_INSTALL 包构建是否生成单个文件Whether package build produces single file OFFOFF
DEFAULT_CHARSETDEFAULT_CHARSET 默认服务器字符集The default server character set utf8mb4utf8mb4
DEFAULT_COLLATIONDEFAULT_COLLATION 默认服务器排序规则The default server collation utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci
DISABLE_PSI_CONDDISABLE_PSI_COND 排除性能架构条件检测Exclude Performance Schema condition instrumentation OFFOFF
DISABLE_PSI_DATA_LOCKDISABLE_PSI_DATA_LOCK 排除性能架构数据锁定检测Exclude the performance schema data lock instrumentation OFFOFF
DISABLE_PSI_ERRORDISABLE_PSI_ERROR 排除性能架构服务器错误检测Exclude the performance schema server error instrumentation OFFOFF
DISABLE_PSI_FILEDISABLE_PSI_FILE 排除性能架构文件检测Exclude Performance Schema file instrumentation OFFOFF
DISABLE_PSI_IDLEDISABLE_PSI_IDLE 排除性能架构空闲检测Exclude Performance Schema idle instrumentation OFFOFF
DISABLE_PSI_MEMORYDISABLE_PSI_MEMORY 排除性能架构内存检测Exclude Performance Schema memory instrumentation OFFOFF
DISABLE_PSI_METADATADISABLE_PSI_METADATA 排除性能架构元数据检测Exclude Performance Schema metadata instrumentation OFFOFF
DISABLE_PSI_MUTEXDISABLE_PSI_MUTEX 排除性能架构互斥检测Exclude Performance Schema mutex instrumentation OFFOFF
DISABLE_PSI_PSDISABLE_PSI_PS 排除性能架构准备好的语句Exclude the performance schema prepared statements OFFOFF
DISABLE_PSI_RWLOCKDISABLE_PSI_RWLOCK 排除性能架构 rwlock 检测Exclude Performance Schema rwlock instrumentation OFFOFF
DISABLE_PSI_SOCKETDISABLE_PSI_SOCKET 排除性能架构套接字检测Exclude Performance Schema socket instrumentation OFFOFF
DISABLE_PSI_SPDISABLE_PSI_SP 排除性能架构存储程序检测Exclude Performance Schema stored program instrumentation OFFOFF
DISABLE_PSI_STAGEDISABLE_PSI_STAGE 排除性能架构阶段检测Exclude Performance Schema stage instrumentation OFFOFF
DISABLE_PSI_STATEMENTDISABLE_PSI_STATEMENT 排除性能架构语句检测Exclude Performance Schema statement instrumentation OFFOFF
DISABLE_PSI_STATEMENT_DIGESTDISABLE_PSI_STATEMENT_DIGEST 排除性能架构 statements_digest 检测Exclude Performance Schema statements_digest instrumentation OFFOFF
DISABLE_PSI_TABLEDISABLE_PSI_TABLE 排除性能架构表检测Exclude Performance Schema table instrumentation OFFOFF
DISABLE_PSI_THREADDISABLE_PSI_THREAD 排除性能架构线程检测Exclude the performance schema thread instrumentation OFFOFF
DISABLE_PSI_TRANSACTIONDISABLE_PSI_TRANSACTION 排除性能架构事务检测Exclude the performance schema transaction instrumentation OFFOFF
ENABLED_LOCAL_INFILEENABLED_LOCAL_INFILE 是否为 LOAD DATA 启用 LOCALWhether to enable LOCAL for LOAD DATA OFFOFF
ENABLED_PROFILINGENABLED_PROFILING 是否启用查询分析代码Whether to enable query profiling code ONON
ENABLE_EXPERIMENTAL_SYSVARSENABLE_EXPERIMENTAL_SYSVARS 是否启用实验性 InnoDB 系统变量Whether to enabled experimental InnoDB system variables OFFOFF
ENABLE_GCOVENABLE_GCOV 是否包含 gcov 支持Whether to include gcov support
ENABLE_GPROFENABLE_GPROF 启用 gprof(仅限优化的 Linux 版本)Enable gprof (optimized Linux builds only) OFFOFF
FORCE_COLORED_OUTPUTFORCE_COLORED_OUTPUT 是否对编译器输出进行着色Whether to colorize compiler output OFFOFF
FORCE_INSOURCE_BUILDFORCE_INSOURCE_BUILD 是否强制进行源内构建Whether to force an in-source build OFFOFF
FORCE_UNSUPPORTED_COMPILERFORCE_UNSUPPORTED_COMPILER 是否允许不支持的编译器编译器Whether to permit unsupported compilers OFFOFF
FPROFILE_GENERATEFPROFILE_GENERATE 是否生成配置文件引导优化数据Whether to generate profile guided optimization data OFFOFF
FPROFILE_USEFPROFILE_USE 是否使用配置文件引导优化数据Whether to use profile guided optimization data OFFOFF
HAVE_PSI_MEMORY_INTERFACEHAVE_PSI_MEMORY_INTERFACE 为动态存储中使用的内存分配函数启用性能架构内存跟踪模块过度对齐的类型Enable performance schema memory tracing module for memory allocation functions used in dynamic storage of over-aligned types OFFOFF
IGNORE_AIO_CHECKIGNORE_AIO_CHECK 使用-DBUILD_CONFIG=mysql_release,忽略 libaio 检查With -DBUILD_CONFIG=mysql_release, ignore libaio check OFFOFF
INSTALL_BINDIRINSTALL_BINDIR 用户可执行文件目录User executables directory PREFIX/binPREFIX/bin
INSTALL_DOCDIRINSTALL_DOCDIR 文档目录Documentation directory PREFIX/docsPREFIX/docs
INSTALL_DOCREADMEDIRINSTALL_DOCREADMEDIR 自述文件目录README file directory PREFIXPREFIX
INSTALL_INCLUDEDIRINSTALL_INCLUDEDIR 头文件目录Header file directory PREFIX/includePREFIX/include
INSTALL_INFODIRINSTALL_INFODIR 信息文件目录Info file directory PREFIX/docsPREFIX/docs
INSTALL_LAYOUTINSTALL_LAYOUT 选择预定义安装布局Select predefined installation layout STANDALONESTANDALONE
INSTALL_LIBDIRINSTALL_LIBDIR 库文件目录Library file directory PREFIX/libPREFIX/lib
INSTALL_MANDIRINSTALL_MANDIR 手册页目录Manual page directory PREFIX/manPREFIX/man
INSTALL_MYSQLSHAREDIRINSTALL_MYSQLSHAREDIR 共享数据目录Shared data directory PREFIX/sharePREFIX/share
INSTALL_MYSQLTESTDIRINSTALL_MYSQLTESTDIR mysql-test 目录mysql-test directory PREFIX/mysql-testPREFIX/mysql-test
INSTALL_PKGCONFIGDIRINSTALL_PKGCONFIGDIR mysqlclient.pc pkg-config 文件的目录Directory for mysqlclient.pc pkg-config file INSTALL_LIBDIR/pkgconfigINSTALL_LIBDIR/pkgconfig
INSTALL_PLUGINDIRINSTALL_PLUGINDIR 插件目录Plugin directory PREFIX/lib/pluginPREFIX/lib/plugin
INSTALL_PRIV_LIBDIRINSTALL_PRIV_LIBDIR 安装私有库目录Installation private library directory
INSTALL_SBINDIRINSTALL_SBINDIR 服务器可执行目录Server executable directory PREFIX/binPREFIX/bin
INSTALL_SECURE_FILE_PRIVDIRINSTALL_SECURE_FILE_PRIVDIR secure_file_priv 默认值secure_file_priv default value platform specificplatform specific
INSTALL_SHAREDIRINSTALL_SHAREDIR aclocal/mysql.m4 安装目录aclocal/mysql.m4 installation directory PREFIX/sharePREFIX/share
INSTALL_STATIC_LIBRARIESINSTALL_STATIC_LIBRARIES 是否安装静态库Whether to install static libraries ONON
INSTALL_SUPPORTFILESDIRINSTALL_SUPPORTFILESDIR 额外支持文件目录Extra support files directory PREFIX/support-filesPREFIX/support-files
LINK_RANDOMIZELINK_RANDOMIZE 是否随机化 mysqld 二进制文件中符号的顺序Whether to randomize order of symbols in mysqld binary OFFOFF
LINK_RANDOMIZE_SEEDLINK_RANDOMIZE_SEED LINK_RANDOMIZE 选项的种子值Seed value for LINK_RANDOMIZE option mysqlmysql
MAX_INDEXESMAX_INDEXES 每个表的最大索引Maximum indexes per table 64
MSVC_CPPCHECKMSVC_CPPCHECK 启用 MSVC 代码分析。Enable MSVC code analysis. ONON
MUTEX_TYPEMUTEX_TYPE InnoDB 互斥体类型InnoDB mutex type eventevent
MYSQLX_TCP_PORTMYSQLX_TCP_PORT X 使用的 TCP/IP 端口号插件TCP/IP port number used by X Plugin 33060
MYSQLX_UNIX_ADDRMYSQLX_UNIX_ADDR X 插件使用的 Unix 套接字文件Unix socket file used by X Plugin /tmp/mysqlx.sock/tmp/mysqlx.sock
MYSQL_DATADIRMYSQL_DATADIR 数据目录Data directory
MYSQL_MAINTAINER_MODEMYSQL_MAINTAINER_MODE 是否启用 MySQL 维护者特定开发环境Whether to enable MySQL maintainer-specific development environment OFFOFF
MYSQL_PROJECT_NAMEMYSQL_PROJECT_NAME Windows/macOS 项目名称Windows/macOS project name MySQLMySQL
MYSQL_TCP_PORTMYSQL_TCP_PORT TCP/IP 端口号TCP/IP port number 3306
MYSQL_UNIX_ADDRMYSQL_UNIX_ADDR Unix 套接字文件Unix socket file /tmp/mysql.sock/tmp/mysql.sock
NDB_UTILS_LINK_DYNAMICNDB_UTILS_LINK_DYNAMIC 使 NDB 工具动态链接到 ndbclientCause NDB tools to be dynamically linked to ndbclient
ODBC_INCLUDESODBC_INCLUDES ODBC 包含目录ODBC includes directory
ODBC_LIB_DIRODBC_LIB_DIR ODBC 库目录ODBC library directory
OPTIMIZER_TRACEOPTIMIZER_TRACE 是否支持优化器跟踪Whether to support optimizer tracing
OPTIMIZE_SANITIZER_BUILDSOPTIMIZE_SANITIZER_BUILDS 是否优化消毒剂构建Whether to optimize sanitizer builds ONON
REPRODUCIBLE_BUILDREPRODUCIBLE_BUILD 要格外小心地创建独立于构建位置和 timeTake extra care to create a build result independent of build location and time
SHOW_SUPPRESSED_COMPILER_WARNINGSHOW_SUPPRESSED_COMPILER_WARNING 是否显示抑制的编译器警告且不会因 -Werror 失败。Whether to show suppressed compiler warnings and not fail with -Werror. OFFOFF
SYSCONFDIRSYSCONFDIR 选项文件目录Option file directory
SYSTEMD_PID_DIRSYSTEMD_PID_DIR systemd 下 PID 文件的目录Directory for PID file under systemd /var/run/mysqld/var/run/mysqld
SYSTEMD_SERVICE_NAMESYSTEMD_SERVICE_NAME systemd 下的 MySQL 服务名称Name of MySQL service under systemd mysqldmysqld
TMPDIRTMPDIR tmpdir 默认值tmpdir default value
WIN_DEBUG_NO_INLINEWIN_DEBUG_NO_INLINE 是否禁用函数内联Whether to disable function inlining OFFOFF
WITHOUT_SERVERWITHOUT_SERVER 不构建服务器;仅供内部使用Do not build the server; internal use only OFFOFF
WITHOUT_xxx_STORAGE_ENGINEWITHOUT_xxx_STORAGE_ENGINE 从构建中排除存储引擎 xxxExclude storage engine xxx from build
WITH_ANTWITH_ANT 用于构建 GCS Java 包装器的 Ant 路径Path to Ant for building GCS Java wrapper
WITH_ASANWITH_ASAN 启用 AddressSanitizerEnable AddressSanitizer OFFOFF
WITH_ASAN_SCOPEWITH_ASAN_SCOPE 启用 AddressSanitizer -fsanitize-address-use-after-scope Clang 标志Enable AddressSanitizer -fsanitize-address-use-after-scope Clang flag OFFOFF
WITH_AUTHENTICATION_CLIENT_PLUGINSWITH_AUTHENTICATION_CLIENT_PLUGINS 如果构建了任何相应的服务器身份验证插件,则自动启用Enabled automatically if any corresponding server authentication plugins are built
WITH_AUTHENTICATION_LDAPWITH_AUTHENTICATION_LDAP 无法构建 LDAP 认证插件是否报错Whether to report error if LDAP authentication plugins cannot be built OFFOFF
WITH_AUTHENTICATION_PAMWITH_AUTHENTICATION_PAM 构建 PAM 认证插件Build PAM authentication plugin OFFOFF
WITH_AWS_SDKWITH_AWS_SDK Amazon Web Services 软件开发工具包的位置Location of Amazon Web Services software development kit
WITH_BUILD_IDWITH_BUILD_ID 在 Linux 系统上,生成唯一的构建 IDOn Linux systems, generate a unique build ID ONON
WITH_CLASSPATHWITH_CLASSPATH 构建适用于 Java 的 MySQL 集群连接器时使用的类路径。默认为空字符串。Classpath to use when building MySQL Cluster Connector for Java. Default is an empty string.
WITH_CLIENT_PROTOCOL_TRACINGWITH_CLIENT_PROTOCOL_TRACING 构建客户端协议跟踪框架Build client-side protocol tracing framework ONON
WITH_CURLWITH_CURL curl 库的位置Location of curl library
WITH_DEBUGWITH_DEBUG 是否包含调试支持Whether to include debugging support OFFOFF
WITH_DEFAULT_COMPILER_OPTIONSWITH_DEFAULT_COMPILER_OPTIONS 是否使用默认编译器 optionsWhether to use default compiler options ONON
WITH_DEVELOPER_ENTITLEMENTSWITH_DEVELOPER_ENTITLEMENTS 是否向 macOS 上的所有可执行文件添加“get-task-allow”权限,以便在服务器意外停止时生成核心转储Whether to add the 'get-task-allow' entitlement to all executables on macOS to generate a core dump in the event of an unexpected server halt OFFOFF
WITH_EDITLINEWITH_EDITLINE 使用哪个 libedit/editline 库Which libedit/editline library to use bundledbundled
WITH_ERROR_INSERTWITH_ERROR_INSERT 在 NDB 存储引擎中启用错误注入。不应用于构建用于生产的二进制文件。Enable error injection in the NDB storage engine. Should not be used for building binaries intended for production. OFFOFF
WITH_ICUWITH_ICU ICU 支持类型Type of ICU support bundledbundled
WITH_INNODB_EXTRA_DEBUGWITH_INNODB_EXTRA_DEBUG 是否包含对 InnoDB 的额外调试支持。Whether to include extra debugging support for InnoDB. OFFOFF
WITH_JEMALLOCWITH_JEMALLOC 是否链接-ljemallocWhether to link with -ljemalloc OFFOFF
WITH_LDWITH_LD 是否使用 LLVM lld 或 mold 链接器Whether to use the LLVM lld or mold linker
WITH_LIBEVENTWITH_LIBEVENT 使用哪个 libevent 库Which libevent library to use bundledbundled
WITH_LIBWRAPWITH_LIBWRAP 是否包含 libwrap(TCP 包装器)支持Whether to include libwrap (TCP wrappers) support OFFOFF
WITH_LOCK_ORDERWITH_LOCK_ORDER 是否启用 LOCK_ORDER 工具Whether to enable LOCK_ORDER tooling OFFOFF
WITH_LSANWITH_LSAN 是否运行 LeakSanitizer,不运行 AddressSanitizerWhether to run LeakSanitizer, without AddressSanitizer OFFOFF
WITH_LTOWITH_LTO 启用链接时优化器Enable link-time optimizer OFFOFF
WITH_LZ4WITH_LZ4 LZ4 库支持类型Type of LZ4 library support bundledbundled
WITH_MECABWITH_MECAB 编译梅卡布Compiles MeCab
WITH_MSANWITH_MSAN 启用 MemorySanitizerEnable MemorySanitizer OFFOFF
WITH_MSCRT_DEBUGWITH_MSCRT_DEBUG 启用 Visual Studio CRT 内存泄漏跟踪Enable Visual Studio CRT memory leak tracing OFFOFF
WITH_MYSQLXWITH_MYSQLX 是否禁用 X 协议Whether to disable X Protocol ONON
WITH_NDBWITH_NDB 构建 MySQL NDB Cluster,包括 NDB 存储引擎和所有 NDB 程序Build MySQL NDB Cluster, including NDB storage engine and all NDB programs OFFOFF
WITH_NDBAPI_EXAMPLESWITH_NDBAPI_EXAMPLES 构建 API 示例程序。Build API example programs. OFFOFF
WITH_NDBCLUSTERWITH_NDBCLUSTER NDB 8.0.30 及更早版本:构建 NDB 存储引擎。 NDB 8.0.31 及更高版本:已弃用;使用 WITH_NDB 代替NDB 8.0.30 and earlier: Build NDB storage engine. NDB 8.0.31 and later: Deprecated; use WITH_NDB instead OFFOFF
WITH_NDBCLUSTER_STORAGE_ENGINEWITH_NDBCLUSTER_STORAGE_ENGINE 在 NDB 8.0.31 之前,这仅供内部使用。 NDB 8.0.31 及更高版本:切换(仅)包含 NDBCLUSTER 存储引擎Prior to NDB 8.0.31, this was for internal use only. NDB 8.0.31 and later: toggles (only) inclusion of NDBCLUSTER storage engine ONON
WITH_NDBMTDWITH_NDBMTD 构建多线程数据节点二进制文件Build multithreaded data node binary ONON
WITH_NDB_DEBUGWITH_NDB_DEBUG 生成用于测试或故障排除的调试版本。Produce a debug build for testing or troubleshooting. OFFOFF
WITH_NDB_JAVAWITH_NDB_JAVA 启用 Java 和 ClusterJ 支持的构建。默认启用。仅在 MySQL 集群中受支持。Enable building of Java and ClusterJ support. Enabled by default. Supported in MySQL Cluster only. ONON
WITH_NDB_PORTWITH_NDB_PORT 使用此选项构建的管理服务器使用的默认端口。如果未使用此选项来构建它,则管理服务器的默认端口为 1186。Default 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][none]
WITH_NDB_TESTWITH_NDB_TEST 包括 NDB API 测试Include NDB API test programs. OFFOFF
WITH_NDB_TLS_SEARCH_PATHWITH_NDB_TLS_SEARCH_PATH NDB 程序用于搜索 TLS 证书和密钥文件的默认路径。Default path used by NDB programs to search for TLS certificate and key files. $HOME/ndb-tls$HOME/ndb-tls
WITH_NUMAWITH_NUMA 设置 NUMA 内存分配策略Set NUMA memory allocation policy
WITH_PACKAGE_FLAGSWITH_PACKAGE_FLAGS 对于通常用于 RPM/DEB 包的标志,是否将它们添加到这些平台上的独立构建For flags typically used for RPM/DEB packages, whether to add them to standalone builds on those platforms
WITH_PROTOBUFWITH_PROTOBUF 要使用的 Protocol Buffers 包Which Protocol Buffers package to use bundledbundled
WITH_RAPIDWITH_RAPID 是否构建快速开发周期插件Whether to build rapid development cycle plugins ONON
WITH_RAPIDJSONWITH_RAPIDJSON RapidJSON 支持类型Type of RapidJSON support bundledbundled
WITH_ROUTERWITH_ROUTER 是否构建 MySQL RouterWhether to build MySQL Router ONON
WITH_SASLWITH_SASL 内部使用仅Internal use only
WITH_SHOW_PARSE_TREEWITH_SHOW_PARSE_TREE 支持 SHOW PARSE_TREE 调试语句Support for SHOW PARSE_TREE debugging statement
WITH_SSLWITH_SSL SSL 支持类型Type of SSL support systemsystem
WITH_SYSTEMDWITH_SYSTEMD 启用 systemd 支持文件的安装Enable installation of systemd support files OFFOFF
WITH_SYSTEMD_DEBUGWITH_SYSTEMD_DEBUG 启用其他 systemd 调试信息Enable additional systemd debug information OFFOFF
WITH_SYSTEM_LIBSWITH_SYSTEM_LIBS 设置未明确设置的库选项的系统值Set system value of library options not set explicitly OFFOFF
WITH_TCMALLOCWITH_TCMALLOC 是否与-ltcmalloc 链接。 BUNDLED 仅在 Linux 上受支持Whether to link with -ltcmalloc. BUNDLED is supported on Linux only OFFOFF
WITH_TEST_TRACE_PLUGINWITH_TEST_TRACE_PLUGIN 构建测试协议跟踪插件Build test protocol trace plugin OFFOFF
WITH_TSANWITH_TSAN 启用 ThreadSanitizerEnable ThreadSanitizer OFFOFF
WITH_UBSANWITH_UBSAN 启用未定义行为 SanitizerEnable Undefined Behavior Sanitizer OFFOFF
WITH_UNIT_TESTSWITH_UNIT_TESTS 使用单元测试编译 MySQLCompile MySQL with unit tests ONON
WITH_UNIXODBCWITH_UNIXODBC 启用 unixODBC 支持Enable unixODBC support OFFOFF
WITH_VALGRINDWITH_VALGRIND 是否在 Valgrind 头文件中编译Whether to compile in Valgrind header files OFFOFF
WITH_WIN_JEMALLOCWITH_WIN_JEMALLOC 包含 jemalloc.dll 的目录路径Path to directory containing jemalloc.dll
WITH_ZLIBWITH_ZLIB zlib 支持类型Type of zlib support bundledbundled
WITH_ZSTDWITH_ZSTD zstd 支持类型Type of zstd support bundledbundled
WITH_xxx_STORAGE_ENGINEWITH_xxx_STORAGE_ENGINE 将存储引擎 xxx 静态编译为 serverCompile storage engine xxx statically into server

常规选项General Options

  • -DBUILD_CONFIG=mysql_release -DBUILD_CONFIG=mysql_release

    此选项使用所使用的相同构建选项配置源发行版由 Oracle 为官方 MySQL 版本生成二进制发行版。This option configures a source distribution with the same build options used by Oracle to produce binary distributions for official MySQL releases.

  • -DWITH_BUILD_ID=bool -DWITH_BUILD_ID=bool

    在 Linux 系统上,生成一个唯一的构建 ID,该 ID 用作 build_id 系统变量的值,并在启动时写入 MySQL 服务器日志。将此选项设置为 OFF 可禁用此功能。On Linux systems, generates a unique build ID which is used as the value of the build_id system variable and written to the MySQL server log on startup. Set this option to OFF to disable this feature.

    此选项对 Linux 以外的平台没有影响。This option has no effect on platforms other than Linux.

  • -DBUNDLE_RUNTIME_LIBRARIES=bool -DBUNDLE_RUNTIME_LIBRARIES=bool

    是否将运行时库与 Windows 的服务器 MSI 和 Zip 包捆绑在一起。Whether to bundle runtime libraries with server MSI and Zip packages for Windows.

  • -DCMAKE_BUILD_TYPE=type -DCMAKE_BUILD_TYPE=type

    要生成的构建类型:The type of build to produce:

    • RelWithDebInfo:启用优化并生成调试信息。这是默认的 MySQL 构建类型。RelWithDebInfo: Enable optimizations and generate debugging information. This is the default MySQL build type.

    • Release:启用优化但忽略调试信息以减少构建大小。Release: Enable optimizations but omit debugging information to reduce the build size.

    • Debug:禁用优化并生成调试信息。如果启用了 WITH_DEBUG 选项,也会使用此构建类型。也就是说, -DWITH_DEBUG=1 与 -DCMAKE_BUILD_TYPE=Debug。Debug: Disable optimizations and generate debugging information. This build type is also used if the WITH_DEBUG option is enabled. That is, -DWITH_DEBUG=1 has the same effect as -DCMAKE_BUILD_TYPE=Debug.

    不支持选项值 None 和 MinSizeRel。The option values None and MinSizeRel are not supported.

  • -DCPACK_MONOLITHIC_INSTALL=bool -DCPACK_MONOLITHIC_INSTALL=bool

    此选项影响ma​​ke package操作是生成多个安装包文件还是单个文件。如果禁用,该操作会生成多个安装包文件,如果您只想安装完整 MySQL 安装的子集,这可能很有用。如果启用,它会生成一个文件来安装所有内容。This option affects whether the make package operation produces multiple installation package files or a single file. If disabled, the operation produces multiple installation package files, which may be useful if you want to install only a subset of a full MySQL installation. If enabled, it produces a single file for installing everything.

  • -DFORCE_INSOURCE_BUILD=bool -DFORCE_INSOURCE_BUILD=bool

    定义是否强制进行源内构建。建议使用源外构建,因为它们允许来自同一源的多个构建,并且可以通过删除构建目录来快速执行清理。要强制进行源内构建,请使用 -DFORCE_INSOURCE_BUILD=ON 调用 CMake。Defines whether to force an in-source build. Out-of-source builds are recommended, as they permit multiple builds from the same source, and cleanup can be performed quickly by removing the build directory. To force an in-source build, invoke CMake with -DFORCE_INSOURCE_BUILD=ON.

  • -DFORCE_COLORED_OUTPUT=bool -DFORCE_COLORED_OUTPUT=bool

    定义是否为 gcc 和 clang 在命令行上编译时。默认为 OFF。Defines whether to enable colorized compiler output for gcc and clang when compiling on the command line. Defaults to OFF.

安装布局选项Installation Layout Options

CMAKE_INSTALL_PREFIX 选项指示基本安装目录。其他名称格式为 INSTALL_xxx 的选项指示组件位置相对于前缀进行解释,并且它们的值是相对路径名。它们的值不应包含前缀。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

存储引擎是作为插件构建的。您可以将插件构建为静态模块(编译到服务器中)或动态模块(构建为动态库,必须使用 INSTALL PLUGIN 语句或 --plugin-load 选项才能使用)。某些插件可能不支持静态或动态构建。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.

InnoDB、MyISAM、MERGE、MEMORY 和 CSV 引擎是必需的(始终编译到服务器中),无需显式安装。The InnoDB, MyISAM, MERGE, MEMORY, and CSV engines are mandatory (always compiled into the server) and need not be installed explicitly.

要将存储引擎静态编译到服务器中,请使用 -DWITH_engine_STORAGE_ENGINE=1。一些允许的 engine 值包括 ARCHIVE、BLACKHOLE、EXAMPLE 和 FEDERATED。示例:To compile a storage engine statically into the server, use -DWITH_engine_STORAGE_ENGINE=1. Some permissible engine values are ARCHIVE, BLACKHOLE, EXAMPLE, and FEDERATED. Examples:

-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1

要构建支持 NDB Cluster 的 MySQL,请使用 WITH_NDB 选项。To build MySQL with support for NDB Cluster, use the WITH_NDB option.

Note

如果没有 Performance Schema 支持,则无法进行编译。如果希望在不使用特定类型检测的情况下进行编译,可以使用以下 CMake 选项来完成: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_DATA_LOCK
DISABLE_PSI_ERROR
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

例如,要在不使用互斥检测的情况下进行编译,请使用 -DDISABLE_PSI_MUTEX=1。For example, to compile without mutex instrumentation, configure MySQL using -DDISABLE_PSI_MUTEX=1.

要从构建中排除存储引擎,请使用-DWITH_engine_STORAGE_ENGINE=0。示例:To exclude a storage engine from the build, use -DWITH_engine_STORAGE_ENGINE=0. Examples:

-DWITH_ARCHIVE_STORAGE_ENGINE=0
-DWITH_EXAMPLE_STORAGE_ENGINE=0
-DWITH_FEDERATED_STORAGE_ENGINE=0

还可以使用 -DWITHOUT_engine_STORAGE_ENGINE=1 从构建中排除存储引擎(但首选 -DWITH_engine_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_ARCHIVE_STORAGE_ENGINE=1
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1

如果未为给定存储引擎指定 -DWITH_engine_STORAGE_ENGINE 和 -DWITHOUT_engine_STORAGE_ENGINE,则该引擎将构建为共享模块,如果无法构建为共享模块,则将其排除模块。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

  • -DADD_GDB_INDEX=bool -DADD_GDB_INDEX=bool

    此选项确定是否启用 .gdb_index 部分,这使得在调试器中加载它们的速度更快。默认情况下该选项处于禁用状态。使用 lld 链接器,并通过以下方式禁用。如果使用 lld 或 GNU gold 以外的链接器,则无效。This option determines whether to enable generation of a .gdb_index section in binaries, which makes loading them in a debugger faster. The option is disabled by default. lld linker is used, and is disabled by It has no effect if a linker other than lld or GNU gold is used.

  • -DCOMPILATION_COMMENT=string -DCOMPILATION_COMMENT=string

    有关编译环境的描述性注释。虽然 mysqld 使用 COMPILATION_COMMENT_SERVER,但其他程序使用 COMPILATION_COMMENT。A descriptive comment about the compilation environment. While mysqld uses COMPILATION_COMMENT_SERVER, other programs use COMPILATION_COMMENT.

  • -DCOMPRESS_DEBUG_SECTIONS=bool -DCOMPRESS_DEBUG_SECTIONS=bool

    是否压缩二进制可执行文件的调试部分(仅限 Linux)。压缩可执行调试部分可以节省空间,但代价是构建过程中需要额外的 CPU 时间。Whether to compress the debug sections of binary executables (Linux only). Compressing executable debug sections saves space at the cost of extra CPU time during the build process.

    默认值为 OFF。如果未显式设置此选项,但设置了 COMPRESS_DEBUG_SECTIONS 环境变量,则该选项将从该变量获取其值。The default is OFF. If this option is not set explicitly but the COMPRESS_DEBUG_SECTIONS environment variable is set, the option takes its value from that variable.

  • -DCOMPILATION_COMMENT_SERVER=string -DCOMPILATION_COMMENT_SERVER=string

    有关 mysqld 使用的编译环境的描述性注释(例如,设置version_comment 系统变量)。服务器以外的程序使用 COMPILATION_COMMENT。A descriptive comment about the compilation environment for use by mysqld (for example, to set the version_comment system variable). Programs other than the server use COMPILATION_COMMENT.

  • -DDEFAULT_CHARSET=charset_name -DDEFAULT_CHARSET=charset_name

    服务器字符集。默认情况下,MySQL 使用 utf8mb4 字符集。The server character set. By default, MySQL uses the utf8mb4 character set.

    charset_name 可以是 binary、armscii8、ascii、big5、cp1250、cp1251、cp1256、cp1257、cp850、cp852、cp866、cp932、dec8、eucjpms、euckr、gb2312、gbk、geostd8、greek、hebrew、hp8、keybcs2、koi8r、koi8u、latin1、latin2、latin5、latin7、macce、macroman、sjis、swe7、tis620、ucs2、ujis、utf8mb3、utf8mb4、utf16、utf16le、utf32。charset_name may be one of binary, armscii8, ascii, big5, cp1250, cp1251, cp1256, cp1257, cp850, cp852, cp866, cp932, dec8, eucjpms, euckr, gb2312, gbk, geostd8, greek, hebrew, hp8, keybcs2, koi8r, koi8u, latin1, latin2, latin5, latin7, macce, macroman, sjis, swe7, tis620, ucs2, ujis, utf8mb3, utf8mb4, utf16, utf16le, utf32.

    此值可以在服务器启动时使用 --character-set-server 设置选项。This value can be set at server startup with the --character-set-server option.

  • -DDEFAULT_COLLATION=collation_name -DDEFAULT_COLLATION=collation_name

    服务器排序规则。默认情况下,MySQL 使用 utf8mb4_0900_ai_ci。使用 SHOW COLLATION 语句确定每个字符集可用的排序规则。The server collation. By default, MySQL uses utf8mb4_0900_ai_ci. Use the SHOW COLLATION statement to determine which collations are available for each character set.

    可以在服务器启动时使用 --collation_server 选项。This value can be set at server startup with the --collation_server option.

  • -DDISABLE_PSI_COND=bool -DDISABLE_PSI_COND=bool

    是否排除性能架构条件检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema condition instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_FILE=bool -DDISABLE_PSI_FILE=bool

    是否排除性能架构文件检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema file instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_IDLE=bool -DDISABLE_PSI_IDLE=bool

    是否排除性能模式空闲检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema idle instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_MEMORY=bool -DDISABLE_PSI_MEMORY=bool

    是否排除性能架构内存检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema memory instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_METADATA=bool -DDISABLE_PSI_METADATA=bool

    是否排除性能模式元数据检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema metadata instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_MUTEX=bool -DDISABLE_PSI_MUTEX=bool

    是否排除性能架构互斥检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema mutex instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_RWLOCK=bool -DDISABLE_PSI_RWLOCK=bool

    是否排除性能架构 rwlock 检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema rwlock instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_SOCKET=bool -DDISABLE_PSI_SOCKET=bool

    是否排除性能架构套接字检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema socket instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_SP=bool -DDISABLE_PSI_SP=bool

    是否排除性能模式存储程序检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema stored program instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_STAGE=bool -DDISABLE_PSI_STAGE=bool

    是否排除 Performance Schema 阶段检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema stage instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_STATEMENT=bool -DDISABLE_PSI_STATEMENT=bool

    是否排除 Performance Schema 语句检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema statement instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_STATEMENT_DIGEST=bool -DDISABLE_PSI_STATEMENT_DIGEST=bool

    是否排除性能模式语句摘要检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema statement digest instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_TABLE=bool -DDISABLE_PSI_TABLE=bool

    是否排除性能架构表检测。默认值为 OFF(包含)。Whether to exclude the Performance Schema table instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_PS=bool -DDISABLE_PSI_PS=bool

    排除性能模式准备好的语句实例检测。默认值为 OFF(包含)。Exclude the Performance Schema prepared statements instances instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_THREAD=bool -DDISABLE_PSI_THREAD=bool

    排除性能架构线程检测。默认值为 OFF(包含)。Exclude the Performance Schema thread instrumentation. The default is OFF (include).

    仅在没有任何检测的情况下构建时禁用线程,因为其他检测依赖于线程。Only disable threads when building without any instrumentation, because other instrumentations have a dependency on threads.

  • -DDISABLE_PSI_TRANSACTION=bool -DDISABLE_PSI_TRANSACTION=bool

    排除性能架构事务检测。默认值为 OFF(包含)。Exclude the Performance Schema transaction instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_DATA_LOCK=bool -DDISABLE_PSI_DATA_LOCK=bool

    排除性能架构数据锁定检测。默认值为 OFF(包含)。Exclude the performance schema data lock instrumentation. The default is OFF (include).

  • -DDISABLE_PSI_ERROR=bool -DDISABLE_PSI_ERROR=bool

    排除性能架构服务器错误检测。默认值为 OFF(包含)。Exclude the performance schema server error instrumentation. The default is OFF (include).

  • -DENABLE_EXPERIMENTAL_SYSVARS=bool -DENABLE_EXPERIMENTAL_SYSVARS=bool

    是否启用实验性InnoDB系统变量。实验系统变量适用于那些从事 MySQL 开发的人员,只能在开发或测试环境中使用,并且可能会在未来的 MySQL 版本中删除,恕不另行通知。有关实验性系统变量的信息,请参阅 MySQL 源代码树中的 /storage/innobase/handler/ha_innodb.cc。实验系统变量可以通过搜索“PLUGIN_VAR_EXPERIMENTAL”来识别。Whether to enable experimental InnoDB system variables. Experimental system variables are intended for those engaged in MySQL development, should only be used in a development or test environment, and may be removed without notice in a future MySQL release. For information about experimental system variables, refer to /storage/innobase/handler/ha_innodb.cc in the MySQL source tree. Experimental system variables can be identified by searching for “PLUGIN_VAR_EXPERIMENTAL”.

  • -DENABLE_GCOV=bool -DENABLE_GCOV=bool

    是否包含gcov 支持(仅限 Linux)。Whether to include gcov support (Linux only).

  • -DENABLE_GPROF=bool -DENABLE_GPROF=bool

    是否启用gprof(仅限优化的 Linux 版本)。Whether to enable gprof (optimized Linux builds only).

  • -DENABLED_LOCAL_INFILE=bool -DENABLED_LOCAL_INFILE=bool

    此选项控制 MySQL 客户端库的编译默认 LOCAL 功能。因此,未做出明确安排的客户端会根据 MySQL 构建时指定的 ENABLED_LOCAL_INFILE 设置禁用或启用 LOCAL 功能。This option controls the compiled-in default LOCAL capability for the MySQL client library. Clients that make no explicit arrangements therefore have LOCAL capability disabled or enabled according to the ENABLED_LOCAL_INFILE setting specified at MySQL build time.

    默认情况下,MySQL 二进制发行版中的客户端库是使用 ENABLED_LOCAL_INFILE 已禁用。如果您从源代码编译 MySQL,请根据未做出明确安排的客户端是否应禁用或启用 LOCAL 功能来分别禁用或启用 ENABLED_LOCAL_INFILE 进行配置。By default, the client library in MySQL binary distributions is compiled with ENABLED_LOCAL_INFILE disabled. If you compile MySQL from source, configure it with ENABLED_LOCAL_INFILE disabled or enabled based on whether clients that make no explicit arrangements should have LOCAL capability disabled or enabled, respectively.

    ENABLED_LOCAL_INFILE 控制客户端 LOCAL 功能的默认设置。对于服务器, local_infile 系统变量控制服务器端 LOCAL 功能。要显式地使服务器拒绝或允许 LOAD DATA LOCAL 语句(无论客户端程序和库在构建时或运行时如何配置),请启动 mysqld 分别禁用或启用 --local-infile。 local_infile 也可以在运行时设置。请参阅第 8.1.6 节“LOAD DATA LOCAL 的安全注意事项”。ENABLED_LOCAL_INFILE controls the default for client-side LOCAL capability. For the server, the local_infile system variable controls server-side LOCAL capability. To explicitly cause the server to refuse or permit LOAD DATA LOCAL statements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld with --local-infile disabled or enabled, respectively. local_infile can also be set at runtime. See Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”.

  • -DENABLED_PROFILING=bool -DENABLED_PROFILING=bool

    是否启用查询分析代码(对于SHOW PROFILE 和 SHOW PROFILES 语句)。Whether to enable query profiling code (for the SHOW PROFILE and SHOW PROFILES statements).

  • -DFORCE_UNSUPPORTED_COMPILER=bool -DFORCE_UNSUPPORTED_COMPILER=bool

    默认情况下,CMake 检查支持的编译器的最低版本;要禁用此检查,请使用 -DFORCE_UNSUPPORTED_COMPILER=ON。By default, CMake checks for minimum versions of supported compilers; to disable this check, use -DFORCE_UNSUPPORTED_COMPILER=ON.

  • -DFPROFILE_GENERATE=bool -DFPROFILE_GENERATE=bool

    Whether to generate profile guided optimization (PGO) data. This option is available for experimenting with PGO with GCC. See cmake/fprofile.cmake in the MySQL source distribution for information about using FPROFILE_GENERATE以及FPROFILE_USE. These options have been tested with GCC 8 and 9.Whether to generate profile guided optimization (PGO) data. This option is available for experimenting with PGO with GCC. See cmake/fprofile.cmake in the MySQL source distribution for information about using FPROFILE_GENERATE and FPROFILE_USE. These options have been tested with GCC 8 and 9.

  • -DFPROFILE_USE=bool -DFPROFILE_USE=bool

    Whether to use profile guided optimization (PGO) data. This option is available for experimenting with PGO with GCC. See the cmake/fprofile.cmake file in a MySQL source distribution for information about using FPROFILE_GENERATE以及FPROFILE_USE. These options have been tested with GCC 8 and 9.Whether to use profile guided optimization (PGO) data. This option is available for experimenting with PGO with GCC. See the cmake/fprofile.cmake file in a MySQL source distribution for information about using FPROFILE_GENERATE and FPROFILE_USE. These options have been tested with GCC 8 and 9.

    启用 FPROFILE_USE 还会启用WITH_LTO。Enabling FPROFILE_USE also enables WITH_LTO.

  • -DHAVE_PSI_MEMORY_INTERFACE=bool -DHAVE_PSI_MEMORY_INTERFACE=bool

    是否为过度对齐类型的动态存储中使用的内存分配函数(ut::aligned_name库函数)启用性能架构内存跟踪模块。Whether to enable the performance schema memory tracing module for memory allocation functions (ut::aligned_name library functions) used in dynamic storage of over-aligned types.

  • -DIGNORE_AIO_CHECK=bool -DIGNORE_AIO_CHECK=bool

    如果-DBUILD_CONFIG=mysql_release 选项在 Linux 上给出,默认情况下必须链接 libaio 库。如果您没有 libaio 或不想安装它,可以通过指定 -DIGNORE_AIO_CHECK=1 来禁止对其进行检查。If the -DBUILD_CONFIG=mysql_release option is given on Linux, the libaio library must be linked in by default. If you do not have libaio or do not want to install it, you can suppress the check for it by specifying -DIGNORE_AIO_CHECK=1.

  • -DMAX_INDEXES=num -DMAX_INDEXES=num

    每个表的最大索引数。默认值为 64。最大值为 255。小于 64 的值将被忽略,并使用默认值 64。The maximum number of indexes per table. The default is 64. The maximum is 255. Values smaller than 64 are ignored and the default of 64 is used.

  • -DMYSQL_MAINTAINER_MODE=bool -DMYSQL_MAINTAINER_MODE=bool

    是否启用 MySQL 维护者特定的开发环境。如果启用,此选项会导致编译器警告变为错误。Whether to enable a MySQL maintainer-specific development environment. If enabled, this option causes compiler warnings to become errors.

  • -DWITH_DEVELOPER_ENTITLEMENTS=bool -DWITH_DEVELOPER_ENTITLEMENTS=bool

    是否向所有可执行文件添加 get-task-allow 权限,以便在服务器意外停止时生成核心转储。Whether to add the get-task-allow entitlement to all executables to generate a core dump in the event of an unexpected server halt.

    在 macOS 11+ 上,核心转储仅限于具有 com.apple.security.get-task-allow 权限的进程,此 CMake 选项启用此功能。该权利允许其他进程附加和读取/修改进程内存,并允许 --core-file 按预期运行。On macOS 11+, core dumps are limited to processes with the com.apple.security.get-task-allow entitlement, which this CMake option enables. The entitlement allows other processes to attach and read/modify the processes memory, and allows --core-file to function as expected.

  • -DMUTEX_TYPE=type -DMUTEX_TYPE=type

    InnoDB 使用的互斥类型。选项包括:The mutex type used by InnoDB. Options include:

    • event:使用事件互斥体。这是默认值和原始 InnoDB 互斥体实现。event: Use event mutexes. This is the default value and the original InnoDB mutex implementation.

    • sys:在 UNIX 系统上使用 POSIX 互斥体。在 Windows 上使用 CRITICAL_SECTION 对象(如果可用)。sys: Use POSIX mutexes on UNIX systems. Use CRITICAL_SECTION objects on Windows, if available.

    • futex:使用 Linux futex 而不是条件变量来调度等待线程。futex: Use Linux futexes instead of condition variables to schedule waiting threads.

  • -DMYSQLX_TCP_PORT=port_num -DMYSQLX_TCP_PORT=port_num

    X Plugin 侦听 TCP/IP 的端口号连接。默认值为 33060。The port number on which X Plugin listens for TCP/IP connections. The default is 33060.

    可以在服务器启动时使用 mysqlx_port 系统变量设置该值。This value can be set at server startup with the mysqlx_port system variable.

  • -DMYSQLX_UNIX_ADDR=file_name -DMYSQLX_UNIX_ADDR=file_name

    服务器侦听 X 插件套接字连接的 Unix 套接字文件路径。这必须是绝对路径名。默认为 /tmp/mysqlx.sock。The Unix socket file path on which the server listens for X Plugin socket connections. This must be an absolute path name. The default is /tmp/mysqlx.sock.

    可以在服务器启动时使用 mysqlx_port 系统变量设置该值。This value can be set at server startup with the mysqlx_port system variable.

  • -DMYSQL_PROJECT_NAME=name -DMYSQL_PROJECT_NAME=name

    对于 Windows 或 macOS,要合并到项目文件名中的项目名称。For Windows or macOS, the project name to incorporate into the project file name.

  • -DMYSQL_TCP_PORT=port_num -DMYSQL_TCP_PORT=port_num

    服务器侦听 TCP/IP 连接的端口号。默认值为 3306。The port number on which the server listens for TCP/IP connections. The default is 3306.

    可以在服务器启动时使用 --port 选项设置该值。This value can be set at server startup with the --port option.

  • -DMYSQL_UNIX_ADDR=file_name -DMYSQL_UNIX_ADDR=file_name

    服务器侦听套接字连接的 Unix 套接字文件路径。这必须是绝对路径名。默认值为 /tmp/mysql.sock。The Unix socket file path on which the server listens for socket connections. This must be an absolute path name. The default is /tmp/mysql.sock.

    可以在服务器启动时使用 --socket 选项设置该值。This value can be set at server startup with the --socket option.

  • -DOPTIMIZER_TRACE=bool -DOPTIMIZER_TRACE=bool

    是否支持优化器跟踪。请参阅第 10.15 节“跟踪优化器”。Whether to support optimizer tracing. See Section 10.15, “Tracing the Optimizer”.

  • -DREPRODUCIBLE_BUILD=bool -DREPRODUCIBLE_BUILD=bool

    对于 Linux 系统上的构建,此选项控制是否格外小心地创建独立于构建位置和时间的构建结果。For builds on Linux systems, this option controls whether to take extra care to create a build result independent of build location and time.

    对于 RelWithDebInfo,此选项默认为 ON构建。This option defaults to ON for RelWithDebInfo builds.

  • -DSHOW_SUPPRESSED_COMPILER_WARNINGS=bool -DSHOW_SUPPRESSED_COMPILER_WARNINGS=bool

    显示抑制的编译器警告,并且这样做不会因-Werror而失败。默认为 OFF。Show suppressed compiler warnings, and do so without failing with -Werror. Defaults to OFF.

  • -DWIN_DEBUG_NO_INLINE=bool -DWIN_DEBUG_NO_INLINE=bool

    是否在 Windows 上禁用函数内联。默认值为 OFF(启用内联)。Whether to disable function inlining on Windows. The default is OFF (inlining enabled).

  • -DWITH_LD=string -DWITH_LD=string

    CMake 默认使用标准链接器。可以选择传入 lld 或 mold 来指定备用链接器。 mold 必须是版本 2 或更高版本。CMake uses the standard linker by default. Optionally pass in lld or mold to specify an alternative linker. mold must be version 2 or newer.

    此选项可用于除 Enterprise Linux 之外的基于 Linux 的系统,Enterprise Linux 始终使用 ld 链接器。This option can be used on Linux-based systems other than Enterprise Linux, which always uses the ld linker.

    Note

    以前,选项 USE_LD_LLD 可用于显式启用(默认)或禁用 Clang 的 LLVM lld 链接器。在 MySQL 8.3 中,USE_LD_LLD 已被删除。Previously, the option USE_LD_LLD could be used to enable (the default) or disable explicitly the LLVM lld linker for Clang. In MySQL 8.3, USE_LD_LLD has been removed.

  • -DWITH_ANT=path_name -DWITH_ANT=path_name

    设置 Ant 的路径,构建 GCS Java 包装器时需要。将 WITH_ANT 设置为保存 Ant tarball 或解压存档的目录路径。当未设置 WITH_ANT 时,或者使用特殊值 system 设置时,构建过程会假定 $PATH 中存在二进制 ant。Set the path to Ant, required when building GCS Java wrapper. Set WITH_ANT to the path of a directory where the Ant tarball or unpacked archive is saved. When WITH_ANT is not set, or is set with the special value system, the build process assumes a binary ant exists in $PATH.

  • -DWITH_ASAN=bool -DWITH_ASAN=bool

    是否启用 AddressSanitizer,对于支持它的编译器。默认值为 OFF。Whether to enable the AddressSanitizer, for compilers that support it. The default is OFF.

  • -DWITH_ASAN_SCOPE=bool -DWITH_ASAN_SCOPE=bool

    是否启用 AddressSanitizer -fsanitize-address-use-after-scope Clang 标志以进行范围后使用检测。默认关闭。要使用此选项,还必须启用 -DWITH_ASAN。Whether to enable the AddressSanitizer -fsanitize-address-use-after-scope Clang flag for use-after-scope detection. The default is off. To use this option, -DWITH_ASAN must also be enabled.

  • -DWITH_AUTHENTICATION_CLIENT_PLUGINS=bool -DWITH_AUTHENTICATION_CLIENT_PLUGINS=bool

    如果构建了任何相应的服务器身份验证插件,则会自动启用此选项。因此,其值取决于其他 CMake 选项,不应显式设置。This option is enabled automatically if any corresponding server authentication plugins are built. Its value thus depends on other CMake options and it should not be set explicitly.

  • -DWITH_AUTHENTICATION_LDAP=bool -DWITH_AUTHENTICATION_LDAP=bool

    如果无法构建 LDAP 身份验证插件是否报告错误:Whether to report an error if the LDAP authentication plugins cannot be built:

    • 如果禁用此选项(默认),则在找到所需的头文件和库时构建 LDAP 插件。如果不是,CMake 将显示相关注释。If this option is disabled (the default), the LDAP plugins are built if the required header files and libraries are found. If they are not, CMake displays a note about it.

    • 如果启用此选项,则找不到所需的头文件和库会导致 CMake 产生错误,从而阻止构建服务器。If this option is enabled, a failure to find the required header file and libraries causes CMake to produce an error, preventing the server from being built.

  • -DWITH_AUTHENTICATION_PAM=bool -DWITH_AUTHENTICATION_PAM=bool

    是否为包含此插件的源代码树构建 PAM 身份验证插件。 (请参阅第 8.4.1.5 节“PAM 可插入身份验证”。)如果指定此选项并且无法编译插件,则构建会失败。Whether to build the PAM authentication plugin, for source trees that include this plugin. (See Section 8.4.1.5, “PAM Pluggable Authentication”.) If this option is specified and the plugin cannot be compiled, the build fails.

  • -DWITH_AWS_SDK=path_name -DWITH_AWS_SDK=path_name

    Amazon Web Services 软件开发工具包的位置。The location of the Amazon Web Services software development kit.

  • -DWITH_CLIENT_PROTOCOL_TRACING=bool -DWITH_CLIENT_PROTOCOL_TRACING=bool

    是否将客户端协议跟踪框架构建到客户端库中。默认情况下,此选项处于启用状态。Whether to build the client-side protocol tracing framework into the client library. By default, this option is enabled.

    有关编写协议跟踪客户端插件的信息,请参阅编写协议跟踪插件。For information about writing protocol trace client plugins, see Writing Protocol Trace Plugins.

    另请参阅WITH_TEST_TRACE_PLUGIN 选项。See also the WITH_TEST_TRACE_PLUGIN option.

  • -DWITH_CURL=curl_type -DWITH_CURL=curl_type

    curl 库的位置。 curl_type 可以是 system(使用系统 curl 库)、curl 库的路径名、no|off|none 禁用 curl 支持,或者 bundled 在 extra/curl/ 中使用捆绑的 curl 发行版。The location of the curl library. curl_type can be system (use the system curl library), a path name to the curl library, no|off|none to disable curl support, or bundled to use the bundled curl distribution in extra/curl/.

  • -DWITH_DEBUG=bool -DWITH_DEBUG=bool

    是否包含调试支持。Whether to include debugging support.

    通过调试支持配置 MySQL,您可以在启动服务器时使用 --debug="d,parser_debug" 选项。这会导致用于处理 SQL 语句的 Bison 解析器将解析器跟踪转储到服务器的标准错误输出。通常,此输出会写入错误日志。Configuring MySQL with debugging support enables you to use the --debug="d,parser_debug" option when you start the server. This causes the Bison parser that is used to process SQL statements to dump a parser trace to the server's standard error output. Typically, this output is written to the error log.

    InnoDB 存储引擎的同步调试检查在 UNIV_DEBUG 下定义,并且在使用 WITH_DEBUG 选项编译调试支持时可用。编译调试支持后,innodb_sync_debug 配置选项可用于启用或禁用 InnoDB 同步调试检查。Sync debug checking for the InnoDB storage engine is defined under UNIV_DEBUG and is available when debugging support is compiled in using the WITH_DEBUG option. When debugging support is compiled in, the innodb_sync_debug configuration option can be used to enable or disable InnoDB sync debug checking.

    启用WITH_DEBUG也会启用调试同步(Debug Sync)。该功能用于测试和调试。当编译时包含此功能,运行时默认禁用调试同步。要启用它,可通过启动mysqld并使用--debug-sync-timeout=N选项来实现,其中N是大于 0 的超时值。(默认值为 0,表示禁用调试同步。)N成为单个同步点的默认超时值。Enabling WITH_DEBUG also enables Debug Sync. This facility is used for testing and debugging. When compiled in, Debug Sync is disabled by default at runtime. To enable it, start mysqld with the --debug-sync-timeout=N option, where N is a timeout value greater than 0. (The default value is 0, which disables Debug Sync.) N becomes the default timeout for individual synchronization points.

    该选项InnoDB译调试支持时,存储引擎的WITH_DEBUG同步调试检查Sync debug checking for the InnoDB storage engine is available when debugging support is compiled in using the WITH_DEBUG option.

    有关调试同步工具以及如何使用同步点的说明,请参阅 MySQL 内部结构:测试同步。For a description of the Debug Sync facility and how to use synchronization points, see MySQL Internals: Test Synchronization.

  • -DWITH_EDITLINE=value -DWITH_EDITLINE=value

    哪个libedit/editline库。允许的值为bundled(默认)和system.Which libedit/editline library to use. The permitted values are bundled (the default) and system.

  • -DWITH_ICU={icu_type|path_name} -DWITH_ICU={icu_type|path_name}

    MySQL 使用 Unicode 国际组件 (ICU) 来支持正则表达式操作。 WITH_ICU 选项指示要包含的 ICU 支持类型或要使用的 ICU 安装路径名称。MySQL uses International Components for Unicode (ICU) to support regular expression operations. The WITH_ICU option indicates the type of ICU support to include or the path name to the ICU installation to use.

    • icu_type 可以是以下值之一:icu_type can be one of the following values:

      • bundled:使用与发行版捆绑在一起的 ICU 库。这是默认设置,也是 Windows 唯一支持的选项。bundled: Use the ICU library bundled with the distribution. This is the default, and is the only supported option for Windows.

      • system:使用系统 ICU 库。system: Use the system ICU library.

    • path_name 是要使用的 ICU 安装的路径名称。这比使用 system 的 icu_type 值更好,因为它可以防止 CMake 检测和使用系统上安装的较旧或不正确的 ICU 版本。 (执行相同操作的另一种允许方法是将 WITH_ICU 设置为 system 并将 CMAKE_PREFIX_PATH 选项设置为 path_name。)path_name is the path name to the ICU installation to use. This can be preferable to using the icu_type value of system because it can prevent CMake from detecting and using an older or incorrect ICU version installed on the system. (Another permitted way to do the same thing is to set WITH_ICU to system and set the CMAKE_PREFIX_PATH option to path_name.)

  • -DWITH_INNODB_EXTRA_DEBUG=bool -DWITH_INNODB_EXTRA_DEBUG=bool

    是否包含额外的 InnoDB 调试支持。Whether to include extra InnoDB debugging support.

    启用 WITH_INNODB_EXTRA_DEBUG 打开额外的 InnoDB 调试检查。仅当启用 WITH_DEBUG 时才能启用此选项。Enabling WITH_INNODB_EXTRA_DEBUG turns on extra InnoDB debug checks. This option can only be enabled when WITH_DEBUG is enabled.

  • -DWITH_JEMALLOC=bool -DWITH_JEMALLOC=bool

    是否与-ljemalloc链接。如果启用,内置 malloc()、calloc()、realloc() 和 free() 例程将被禁用。默认值为 OFF。Whether to link with -ljemalloc. If enabled, built-in malloc(), calloc(), realloc(), and free() routines are disabled. The default is OFF.

    WITH_JEMALLOC 和 WITH_TCMALLOC 是互斥的。WITH_JEMALLOC and WITH_TCMALLOC are mutually exclusive.

  • -DWITH_LIBEVENT=string -DWITH_LIBEVENT=string

    要使用哪个libevent库。允许的值为bundled(默认)和system。如果指定了 system 并且找不到系统 libevent 库,则无论如何都会发生错误,并且不会使用捆绑的 libevent。Which libevent library to use. Permitted values are bundled (default) and system. If system is specified and no system libevent library can be found, an error occurs regardless, and the bundled libevent is not used.

    X Plugin 和 MySQL Router 需要 libevent 库。The libevent library is required by X Plugin and MySQL Router.

  • -DWITH_LIBWRAP=bool -DWITH_LIBWRAP=bool

    是否包含 libwrap(TCP 包装器)支持。Whether to include libwrap (TCP wrappers) support.

  • -DWITH_LOCK_ORDER=bool -DWITH_LOCK_ORDER=bool

    是否启用 LOCK_ORDER 工具。默认情况下,此选项处于禁用状态,并且服务器版本不包含任何工具。如果启用了工具,则 LOCK_ORDER 工具可用,并且可以按照第 7.9.3 节“LOCK_ORDER 工具”中的说明使用。Whether to enable LOCK_ORDER tooling. By default, this option is disabled and server builds contain no tooling. If tooling is enabled, the LOCK_ORDER tool is available and can be used as described in Section 7.9.3, “The LOCK_ORDER Tool”.

    Note

    启用WITH_LOCK_ORDER选项后,MySQL 构建需要该flex程序。With the WITH_LOCK_ORDER option enabled, MySQL builds require the flex program.

  • -DWITH_LSAN=bool -DWITH_LSAN=bool

    是否运行 LeakSanitizer,不运行 AddressSanitizer。默认为 OFF。Whether to run LeakSanitizer, without AddressSanitizer. The default is OFF.

  • -DWITH_LTO=bool -DWITH_LTO=bool

    是否启用链接时优化器(如果编译器支持)。默认值为 OFF,除非启用 FPROFILE_USE。Whether to enable the link-time optimizer, if the compiler supports it. The default is OFF unless FPROFILE_USE is enabled.

  • -DWITH_LZ4=lz4_type -DWITH_LZ4=lz4_type

    WITH_LZ4 选项指示 zlib 支持的来源:The WITH_LZ4 option indicates the source of zlib support:

    • bundled:使用与发行版捆绑的 lz4 库。这是默认设置。bundled: Use the lz4 library bundled with the distribution. This is the default.

    • system:使用系统lz4 库。system: Use the system lz4 library.

  • -DWITH_MECAB={disabled|system|path_name} -DWITH_MECAB={disabled|system|path_name}

    使用此选项编译 MeCab 解析器。如果您已将 MeCab 安装到默认安装目录,请设置 -DWITH_MECAB=system。 system 选项适用于使用本机包管理实用程序从源代码或二进制文件执行的 MeCab 安装。如果您将 MeCab 安装到自定义安装目录,请指定 MeCab 安装路径,例如 -DWITH_MECAB=/opt/mecab。如果 system 选项不起作用,则指定 MeCab 安装路径应该在所有情况下都起作用。Use this option to compile the MeCab parser. If you have installed MeCab to its default installation directory, set -DWITH_MECAB=system. The system option applies to MeCab installations performed from source or from binaries using a native package management utility. If you installed MeCab to a custom installation directory, specify the path to the MeCab installation, for example, -DWITH_MECAB=/opt/mecab. If the system option does not work, specifying the MeCab installation path should work in all cases.

    有关信息,请参阅第 14.9.9 节“MeCab 全文解析器”插件”。For related information, see Section 14.9.9, “MeCab Full-Text Parser Plugin”.

  • -DWITH_MSAN=bool -DWITH_MSAN=bool

    是否启用 MemorySanitizer,对于支持的编译器它。默认关闭。Whether to enable MemorySanitizer, for compilers that support it. The default is off.

    要使此选项在启用后生效,链接到 MySQL 的所有库也必须在启用该选项的情况下进行编译。For this option to have an effect if enabled, all libraries linked to MySQL must also have been compiled with the option enabled.

  • -DWITH_MSCRT_DEBUG=bool -DWITH_MSCRT_DEBUG=bool

    是否启用 Visual Studio CRT 内存泄漏跟踪。默认值为 OFF。Whether to enable Visual Studio CRT memory leak tracing. The default is OFF.

  • -DMSVC_CPPCHECK=bool -DMSVC_CPPCHECK=bool

    是否启用 MSVC 代码分析。默认为ON。Whether to enable MSVC code analysis. The default is ON.

  • -DWITH_MYSQLX=bool -DWITH_MYSQLX=bool

    是否构建支持 X 插件。默认值为ON。请参阅第 22 章,使用 MySQL 作为文档存储。Whether to build with support for X Plugin. The default is ON. See Chapter 22, Using MySQL as a Document Store.

  • -DWITH_NUMA=bool -DWITH_NUMA=bool

    显式设置 NUMA 内存分配策略。 CMake 根据当前平台是否支持 NUMA 设置默认的 WITH_NUMA 值。对于不支持 NUMA 的平台,CMake 的行为如下:Explicitly set the NUMA memory allocation policy. CMake sets the default WITH_NUMA value based on whether the current platform has NUMA support. For platforms without NUMA support, CMake behaves as follows:

    • 如果没有 NUMA 选项(正常情况),CMake 会正常继续,仅生成此警告:NUMA 库丢失或所需版本不可用。With no NUMA option (the normal case), CMake continues normally, producing only this warning: NUMA library missing or required version not available.

    • 使用 -DWITH_NUMA=ON,CMake 中止并出现以下错误:NUMA 库丢失或所需版本不可用。With -DWITH_NUMA=ON, CMake aborts with this error: NUMA library missing or required version not available.

  • -DWITH_PACKAGE_FLAGS=bool -DWITH_PACKAGE_FLAGS=bool

    对于通常用于 RPM 和 Debian 软件包的标志,是否将它们添加到这些平台上的独立构建中。对于非调试版本,默认值为 ON。For flags typically used for RPM and Debian packages, whether to add them to standalone builds on those platforms. The default is ON for nondebug builds.

  • -DWITH_PROTOBUF=protobuf_type -DWITH_PROTOBUF=protobuf_type

    要使用的 Protocol Buffers 包。 protobuf_type 可以是以下值之一:Which Protocol Buffers package to use. protobuf_type can be one of the following values:

    • bundled:使用与发行版捆绑在一起的包。这是默认设置。 (可选)使用 INSTALL_PRIV_LIBDIR 修改动态 Protobuf 库目录。bundled: Use the package bundled with the distribution. This is the default. Optionally use INSTALL_PRIV_LIBDIR to modify the dynamic Protobuf library directory.

    • system:使用系统上安装的软件包。system: Use the package installed on the system.

    其他值将被忽略,并回退到 bundled.Other values are ignored, with a fallback to bundled.

  • -DWITH_RAPID=bool -DWITH_RAPID=bool

    是否构建快速开发周期插件。启用后,将在包含这些插件的构建树中创建一个 rapid 目录。禁用后,不会在构建树中创建 rapid 目录。默认值为 ON,除非 rapid 目录已从源代码树中删除,在这种情况下,默认值为 OFF。Whether to build the rapid development cycle plugins. When enabled, a rapid directory is created in the build tree containing these plugins. When disabled, no rapid directory is created in the build tree. The default is ON, unless the rapid directory is removed from the source tree, in which case the default becomes OFF.

  • -DWITH_RAPIDJSON=rapidjson_type -DWITH_RAPIDJSON=rapidjson_type

    要包含的 RapidJSON 库支持的类型。 rapidjson_type 可以是以下值之一:The type of RapidJSON library support to include. rapidjson_type can be one of the following values:

    • bundled:使用与发行版捆绑的 RapidJSON 库。这是默认值。bundled: Use the RapidJSON library bundled with the distribution. This is the default.

    • system:使用系统 RapidJSON 库。需要 1.1.0 或更高版本。system: Use the system RapidJSON library. Version 1.1.0 or later is required.

  • -DWITH_ROUTER=bool -DWITH_ROUTER=bool

    是否构建 MySQL Router。默认为 ON。Whether to build MySQL Router. The default is ON.

  • -DWITH_SASL=value -DWITH_SASL=value

    内部使用仅。 Windows 上不支持。Internal use only. Not supported on Windows.

  • -DWITH_SSL={ssl_type|path_name} -DWITH_SSL={ssl_type|path_name}

    为了支持加密连接、随机数生成的熵以及其他与加密相关的操作,MySQL 必须使用 SSL 库构建。此选项指定要使用哪个 SSL 库。For support of encrypted connections, entropy for random number generation, and other encryption-related operations, MySQL must be built using an SSL library. This option specifies which SSL library to use.

    • ssl_type 可以是以下值之一:ssl_type can be one of the following values:

      • system:使用系统 OpenSSL 库。这是默认设置。system: Use the system OpenSSL library. This is the default.

        在 macOS 和 Windows 上,使用 system 将 MySQL 配置为构建,就像使用指向手动安装的 OpenSSL 库的path_name 调用 CMake 一样。这是因为他们没有系统 SSL 库。在 macOS 上,brew install openssl 安装到 /usr/local/opt/openssl,以便 system 可以找到它。在 Windows 上,它检查 %ProgramFiles%/OpenSSL、%ProgramFiles%/OpenSSL-Win32、%ProgramFiles%/OpenSSL-Win64、C:/OpenSSL、C:/OpenSSL-Win32 和 C:/OpenSSL-Win64.On macOS and Windows, using system configures MySQL to build as if CMake was invoked with path_name points to a manually installed OpenSSL library. This is because they do not have system SSL libraries. On macOS, brew install openssl installs to /usr/local/opt/openssl so that system can find it. On Windows, it checks %ProgramFiles%/OpenSSL, %ProgramFiles%/OpenSSL-Win32, %ProgramFiles%/OpenSSL-Win64, C:/OpenSSL, C:/OpenSSL-Win32, and C:/OpenSSL-Win64.

      • yes:这是 system 的同义词。yes: This is a synonym for system.

      • opensslversion:使用备用 OpenSSL 系统包,例如 openssl11,或 EL8 上的 openssl3(或 openssl3-fips)。opensslversion: Use an alternate OpenSSL system package such as openssl11 on EL7, or openssl3 (or openssl3-fips) on EL8.

        身份验证插件(例如 LDAP 和 Kerberos)已被禁用,因为它们不支持这些替代版本的 OpenSSL。Authentication plugins, such as LDAP and Kerberos, are disabled as they do not support these alternative versions of OpenSSL.

    • path_name 是要使用的 OpenSSL 安装的路径名。这比使用 ssl_type 值 system 更好,因为它可以防止 CMake 检测和使用系统上安装的较旧或不正确的 OpenSSL 版本。 (执行相同操作的另一种允许方法是将 WITH_SSL 设置为 system 并将 CMAKE_PREFIX_PATH 选项设置为 path_name。)path_name is the path name to the OpenSSL installation to use. This can be preferable to using the ssl_type value system because it can prevent CMake from detecting and using an older or incorrect OpenSSL version installed on the system. (Another permitted way to do the same thing is to set WITH_SSL to system and set the CMAKE_PREFIX_PATH option to path_name.)

    有关配置 SSL 库的更多信息,请参阅 第 2.8.6 节,“配置 SSL 库支持”。For additional information about configuring the SSL library, see Section 2.8.6, “Configuring SSL Library Support”.

  • -DWITH_SHOW_PARSE_TREE=bool -DWITH_SHOW_PARSE_TREE=bool

    在服务器中启用对 SHOW PARSE_TREE 的支持,仅用于开发和调试。不用于发布版本或在生产中受支持。Enables support for SHOW PARSE_TREE in the server, used in development and debugging only. Not used for release builds or supported in production.

  • -DWITH_SYSTEMD=bool -DWITH_SYSTEMD=bool

    是否启用安装systemd 支持文件。默认情况下,此选项处于禁用状态。启用后,将安装 systemd 支持文件,但不会安装 mysqld_safe 等脚本和 System V 初始化脚本。在 systemd 不可用的平台上,启用 WITH_SYSTEMD 会导致 CMake 出现错误。Whether to enable installation of systemd support files. By default, this option is disabled. When enabled, systemd support files are installed, and scripts such as mysqld_safe and the System V initialization script are not installed. On platforms where systemd is not available, enabling WITH_SYSTEMD results in an error from CMake.

    使用此选项构建服务器时, MySQL 在服务器的错误日志中包含所有 systemd 消息(请参阅第 7.4.2 节“错误日志”)。When the server was built using this option, MySQL includes all systemd messages in the server's error log (see Section 7.4.2, “The Error Log”).

    有关使用 systemd 的更多信息,请参阅第 2.5.9 节,“使用 systemd 管理 MySQL 服务器”。该部分还包括有关指定选项的信息,否则在 [mysqld_safe] 选项组中指定。由于使用 systemd 时未安装 mysqld_safe,因此必须以其他方式指定此类选项。For more information about using systemd, see Section 2.5.9, “Managing MySQL Server with systemd”. That section also includes information about specifying options otherwise specified in [mysqld_safe] option groups. Because mysqld_safe is not installed when systemd is used, such options must be specified another way.

  • -DWITH_SYSTEM_LIBS=bool -DWITH_SYSTEM_LIBS=bool

    此选项用作 “umbrella” 选项,用于设置以下任何未明确设置的 CMake 选项的 system 值:WITH_CURL、WITH_EDITLINE、WITH_ICU、WITH_LIBEVENT、WITH_LZ4、WITH_LZMA,WITH_PROTOBUF,WITH_RE2,WITH_SSL、WITH_ZLIB、WITH_ZSTD。This option serves as an “umbrella” option to set the system value of any of the following CMake options that are not set explicitly: WITH_CURL, WITH_EDITLINE, WITH_ICU, WITH_LIBEVENT, WITH_LZ4, WITH_LZMA, WITH_PROTOBUF, WITH_RE2, WITH_SSL, WITH_ZLIB, WITH_ZSTD.

  • -DWITH_SYSTEMD_DEBUG=bool -DWITH_SYSTEMD_DEBUG=bool

    是否为使用systemd运行 MySQL 的平台生成额外的systemd调试信息。默认值为 OFF。Whether to produce additional systemd debugging information, for platforms on which systemd is used to run MySQL. The default is OFF.

  • -DWITH_TCMALLOC=bool -DWITH_TCMALLOC=bool

    是否与-ltcmalloc链接。如果启用,内置 malloc()、calloc()、realloc() 和 free() 例程将被禁用。默认值为 OFF。Whether to link with -ltcmalloc. If enabled, built-in malloc(), calloc(), realloc(), and free() routines are disabled. The default is OFF.

    从 MySQL 8.4.1 开始,源代码中包含 tcmalloc 库;您可以通过将此选项设置为 BUNDLED 来使构建使用捆绑版本。 BUNDLED 仅在 Linux 系统上受支持。Beginning with MySQL 8.4.1, a tcmalloc library is included in the source; you can cause the build to use the bundled version by setting this option to BUNDLED. BUNDLED is supported on Linux systems only.

    WITH_TCMALLOC 和 WITH_JEMALLOC 是互斥的。WITH_TCMALLOC and WITH_JEMALLOC are mutually exclusive.

  • -DWITH_TEST_TRACE_PLUGIN=bool -DWITH_TEST_TRACE_PLUGIN=bool

    是否构建测试协议跟踪客户端插件(请参阅使用测试协议跟踪插件)。默认情况下,此选项处于禁用状态。除非启用 WITH_CLIENT_PROTOCOL_TRACING 选项,否则启用此选项无效。如果 MySQL 配置为启用这两个选项,则使用内置的测试协议跟踪插件构建 libmysqlclient 客户端库,并且所有标准 MySQL 客户端都会加载该插件。然而,即使启用了测试插件,默认情况下也没有效果。使用环境变量可以控制插件;请参阅使用测试协议跟踪插件。Whether to build the test protocol trace client plugin (see Using the Test Protocol Trace Plugin). By default, this option is disabled. Enabling this option has no effect unless the WITH_CLIENT_PROTOCOL_TRACING option is enabled. If MySQL is configured with both options enabled, the libmysqlclient client library is built with the test protocol trace plugin built in, and all the standard MySQL clients load the plugin. However, even when the test plugin is enabled, it has no effect by default. Control over the plugin is afforded using environment variables; see Using the Test Protocol Trace Plugin.

    Note

    不要启用WITH_TEST_TRACE_PLUGIN 选项(如果您想使用自己的协议跟踪插件)选项,因为一次只能加载一个此类插件,并且尝试加载第二个插件时会发生错误。如果您已经构建了启用了测试协议跟踪插件以了解其工作原理的 MySQL,则必须在不使用它的情况下重新构建 MySQL,然后才能使用自己的插件。Do not enable the WITH_TEST_TRACE_PLUGIN option if you want to use your own protocol trace plugins because only one such plugin can be loaded at a time and an error occurs for attempts to load a second one. If you have already built MySQL with the test protocol trace plugin enabled to see how it works, you must rebuild MySQL without it before you can use your own plugins.

    有关编写跟踪插件的信息,请参阅编写协议跟踪插件。For information about writing trace plugins, see Writing Protocol Trace Plugins.

  • -DWITH_TSAN=bool -DWITH_TSAN=bool

    是否启用 ThreadSanitizer,对于支持它的编译器。默认关闭。Whether to enable the ThreadSanitizer, for compilers that support it. The default is off.

  • -DWITH_UBSAN=bool -DWITH_UBSAN=bool

    是否为编译器启用未定义行为清理程序支持它。默认关闭。Whether to enable the Undefined Behavior Sanitizer, for compilers that support it. The default is off.

  • -DWITH_UNIT_TESTS={ON|OFF} -DWITH_UNIT_TESTS={ON|OFF}

    如果启用,则使用单元测试编译 MySQL。默认值为 ON,除非未编译服务器。If enabled, compile MySQL with unit tests. The default is ON unless the server is not being compiled.

  • -DWITH_UNIXODBC=1 -DWITH_UNIXODBC=1

    为 Connector/ODBC 启用 unixODBC 支持。Enables unixODBC support, for Connector/ODBC.

  • -DWITH_VALGRIND=bool -DWITH_VALGRIND=bool

    是否在 Valgrind 头文件中编译,这会公开 Valgrind API 到 MySQL 代码。默认值为 OFF。Whether to compile in the Valgrind header files, which exposes the Valgrind API to MySQL code. The default is OFF.

    要生成 Valgrind 感知的调试版本,-DWITH_VALGRIND=1 通常与 -DWITH_DEBUG=1。请参阅构建调试配置。To generate a Valgrind-aware debug build, -DWITH_VALGRIND=1 normally is combined with -DWITH_DEBUG=1. See Building Debug Configurations.

  • -DWITH_WIN_JEMALLOC=string -DWITH_WIN_JEMALLOC=string

    在 Windows 上,传入包含 jemalloc.dll 的目录路径以启用 jemalloc 功能。构建系统将 jemalloc.dll 复制到与 mysqld.exe 和/或 mysqld-debug.exe 相同的目录,并利用它进行内存管理操作。如果未找到 jemalloc.dll 或未导出所需函数,则使用标准内存函数。信息级别日志消息记录是否找到并使用 jemalloc。On Windows, pass in a path to a directory containing jemalloc.dll to enable jemalloc functionality. The build system copies jemalloc.dll to the same directory as mysqld.exe and/or mysqld-debug.exe and utilizes it for memory management operations. Standard memory functions are used if jemalloc.dll is not found or does not export the required functions. An INFORMATION level log message records whether or not jemalloc is found and used.

    此选项针对 Windows 的官方 MySQL 二进制文件启用。This option is enabled for official MySQL binaries for Windows.

  • -DWITH_ZLIB=zlib_type -DWITH_ZLIB=zlib_type

    某些功能要求服务器构建时支持压缩库,例如 COMPRESS() 和 UNCOMPRESS() 函数,以及客户端/服务器协议的压缩。 WITH_ZLIB 选项指示 zlib 支持的来源:Some features require that the server be built with compression library support, such as the COMPRESS() and UNCOMPRESS() functions, and compression of the client/server protocol. The WITH_ZLIB option indicates the source of zlib support:

    zlib 支持的最低版本为 1.2.13。The minimum supported version of zlib is 1.2.13.

    • bundled:使用与发行版捆绑的zlib 库。这是默认设置。bundled: Use the zlib library bundled with the distribution. This is the default.

    • system:使用系统 zlib 库。system: Use the system zlib library.

  • -DWITH_ZSTD=zstd_type -DWITH_ZSTD=zstd_type

    使用 zstd 算法进行连接压缩(请参阅第 6.2.8 节“连接压缩控制”)要求使用 zstd 库支持构建服务器。 WITH_ZSTD 选项指示 zstd 支持的来源:Connection compression using the zstd algorithm (see Section 6.2.8, “Connection Compression Control”) requires that the server be built with zstd library support. The WITH_ZSTD option indicates the source of zstd support:

    • bundled:使用与发行版捆绑的 zstd 库。这是默认值。bundled: Use the zstd library bundled with the distribution. This is the default.

    • system:使用系统 zstd 库。system: Use the system zstd library.

  • -DWITHOUT_SERVER=bool -DWITHOUT_SERVER=bool

    是否在没有 MySQL Server 的情况下构建。默认值为“关闭”,这会构建服务器。Whether to build without MySQL Server. The default is OFF, which does build the server.

    这被认为是一个实验性选项;最好与服务器一起构建。This is considered an experimental option; it is preferred to build with the server.

    此选项还可以阻止构建 NDB 存储引擎或任何 NDB 二进制文件,包括管理和数据节点程序。This option also prevents building of the NDB storage engine or any NDB binaries including management and data node programs.

编译器标志Compiler Flags

要指定您自己的 C 和 C++ 编译器标志,对于不影响优化的标志,请使用 CMAKE_C_FLAGS 和 CMAKE_CXX_FLAGS CMake 选项。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.

在提供您自己的编译器标志时,您可能还需要指定 CMAKE_BUILD_TYPE。When providing your own compiler flags, you might want to specify CMAKE_BUILD_TYPE as well.

例如,要在 64 位 Linux 计算机上创建 32 位版本构建,请执行以下操作: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

如果您设置影响优化的标志(-Onumber),您必须设置 CMAKE_C_FLAGS_build_type 和/或 CMAKE_CXX_FLAGS_build_type 选项,其中 build_type 对应于 CMAKE_BUILD_TYPE 值。要为默认构建类型 (RelWithDebInfo) 指定不同的优化,请设置 CMAKE_C_FLAGS_RELWITHDEBINFO 和 CMAKE_CXX_FLAGS_RELWITHDEBINFO 选项。例如,要使用 -O3 和调试符号在 Linux 上进行编译,请执行以下操作: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"

编译 NDB Cluster 的 CMake 选项CMake Options for Compiling NDB Cluster

要在支持 NDB Cluster 的情况下进行编译,可以使用 -DWITH_NDB,这会导致构建包含 NDB 存储引擎和所有 NDB 程序。默认情况下启用此选项。要阻止构建 NDB 存储引擎插件,请使用 -DWITH_NDBCLUSTER_STORAGE_ENGINE=OFF。可以使用本节中列出的其他选项来控制构建的其他方面。To compile with support for NDB Cluster, you can use -DWITH_NDB, which causes the build to include the NDB storage engine and all NDB programs. This option is enabled by default. To prevent building of the NDB storage engine plugin, use -DWITH_NDBCLUSTER_STORAGE_ENGINE=OFF. Other aspects of the build can be controlled using the other options listed in this section.

构建具有 NDB Cluster 支持的 MySQL 源时适用以下选项。The following options apply when building the MySQL sources with NDB Cluster support.

  • -DNDB_UTILS_LINK_DYNAMIC={ON|OFF} -DNDB_UTILS_LINK_DYNAMIC={ON|OFF}

    控制 NDB 实用程序,例如 ndb_drop_table与 ndbclient 静态(OFF)或动态(ON)链接; OFF(静态链接)是默认值。通常在构建它们时使用静态链接以避免 LD_LIBRARY_PATH 出现问题,或者在安装多个版本的 ndbclient 时使用静态链接。此选项用于创建 Docker 映像以及可能的其他情况,在这些情况下,目标环境需要精确控制,并且需要减小映像大小。Controls whether NDB utilities such as ndb_drop_table are linked with ndbclient statically (OFF) or dynamically (ON); OFF (static linking) is the default. Normally static linking is used when building these to avoid problems with LD_LIBRARY_PATH, or when multiple versions of ndbclient are installed. This option is intended for creating Docker images and possibly other cases in which the target environment is subject to precise control and it is desirable to reduce image size.

  • -DWITH_CLASSPATH=path -DWITH_CLASSPATH=path

    设置用于构建 Java 的 MySQL NDB Cluster Connector 的类路径。默认为空。如果使用 -DWITH_NDB_JAVA=OFF,则忽略此选项。Sets the classpath for building MySQL NDB Cluster Connector for Java. The default is empty. This option is ignored if -DWITH_NDB_JAVA=OFF is used.

  • -DWITH_ERROR_INSERT={ON|OFF} -DWITH_ERROR_INSERT={ON|OFF}

    在 NDB 内核中启用错误注入。仅用于测试;不适用于构建生产二进制文件。默认为 OFF。Enables error injection in the NDB kernel. For testing only; not intended for use in building production binaries. The default is OFF.

  • -DWITH_NDB={ON|OFF} -DWITH_NDB={ON|OFF}

    构建 MySQL NDB 集群;构建 NDB 插件和所有 NDB Cluster 程序。Build MySQL NDB Cluster; build the NDB plugin and all NDB Cluster programs.

  • -DWITH_NDBAPI_EXAMPLES={ON|OFF} -DWITH_NDBAPI_EXAMPLES={ON|OFF}

    在 storage/ndb/ndbapi-examples/。有关这些的信息,请参阅 NDB API 示例。Build NDB API example programs in storage/ndb/ndbapi-examples/. See NDB API Examples, for information about these.

  • -DWITH_NDBCLUSTER_STORAGE_ENGINE={ON|OFF} -DWITH_NDBCLUSTER_STORAGE_ENGINE={ON|OFF}

    (仅)控制构建中是否包含 NDBCLUSTER 存储引擎; WITH_NDB 自动启用此选项,因此建议您使用 WITH_NDB。Controls (only) whether the NDBCLUSTER storage engine is included in the build; WITH_NDB enables this option automatically, so it is recommended that you use WITH_NDB instead.

  • -DWITH_NDBCLUSTER={ON|OFF}(已弃用) -DWITH_NDBCLUSTER={ON|OFF} (DEPRECATED)

    构建和链接以支持NDB mysqld 中的存储引擎。Build and link in support for the NDB storage engine in mysqld.

    此选项已弃用,最终将被删除;请改用 WITH_NDB。This option is deprecated and subject to eventual removal; use WITH_NDB instead.

  • -DWITH_NDBMTD={ON|OFF} -DWITH_NDBMTD={ON|OFF}

    构建多线程数据节点可执行文件ndbmtd。默认值为 ON。Build the multithreaded data node executable ndbmtd. The default is ON.

  • -DWITH_NDB_DEBUG={ON|OFF} -DWITH_NDB_DEBUG={ON|OFF}

    启用构建 NDB Cluster 二进制文件的调试版本。默认情况下,这是 OFF。Enable building the debug versions of the NDB Cluster binaries. This is OFF by default.

  • -DWITH_NDB_JAVA={ON|OFF} -DWITH_NDB_JAVA={ON|OFF}

    启用使用 Java 支持构建 NDB Cluster,包括对 ClusterJ 的支持(请参阅适用于 Java 的 MySQL NDB Cluster Connector)。Enable building NDB Cluster with Java support, including support for ClusterJ (see MySQL NDB Cluster Connector for Java).

    此选项默认为ON。如果您不希望编译带有 Java 支持的 NDB Cluster,则必须在运行 CMake 时指定 -DWITH_NDB_JAVA=OFF 显式禁用它。否则,如果找不到 Java,则构建配置将失败。This option is ON by default. If you do not wish to compile NDB Cluster with Java support, you must disable it explicitly by specifying -DWITH_NDB_JAVA=OFF when running CMake. Otherwise, if Java cannot be found, configuration of the build fails.

  • -DWITH_NDB_PORT=port -DWITH_NDB_PORT=port

    导致 NDB Cluster 管理服务器(ndb_mgmd)默认情况下,构建为使用此port。如果未设置此选项,默认情况下生成的管理服务器会尝试使用端口 1186。Causes the NDB Cluster management server (ndb_mgmd) that is built to use this port by default. If this option is unset, the resulting management server tries to use port 1186 by default.

  • -DWITH_NDB_TEST={ON|OFF} -DWITH_NDB_TEST={ON|OFF}

    如果启用,请包含一组 NDB API 测试程序。默认为OFF。If enabled, include a set of NDB API test programs. The default is OFF.

  • -DWITH_NDB_TLS_SEARCH_PATH=path -DWITH_NDB_TLS_SEARCH_PATH=path

    设置ndb_sign_keys 和其他用于 TLS 证书和密钥文件的 NDB 程序。Set the default path searched by ndb_sign_keys and other NDB programs for TLS certificate and key files.

    Windows 平台的默认值为 $HOMEDIR/ndb-tls;对于其他平台,例如 Linux,它是$HOME/ndb-tls。The default for Windows platforms is $HOMEDIR/ndb-tls; for other platforms, such as Linux, it is $HOME/ndb-tls.