MySQL Source-Configuration Options

本文介绍了使用CMake配置MySQL源码的各种选项,包括一般选项、安装布局选项、特性选项及编译器标志等,帮助开发者更好地理解如何定制MySQL的构建过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html#option_cmake_storage_engine_options

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.12. MySQL Source-Configuration Option Reference (CMake)

FormatsDescriptionDefaultIntroducedRemoved
BUILD_CONFIGUse same build options as official releases  
CMAKE_BUILD_TYPEType of build to produceRelWithDebInfo  
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  
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 support5.6.3 
ENABLE_GPROFEnable gprof (optimized Linux builds only)OFF5.6.6 
ENABLED_LOCAL_INFILEWhether to enable LOCAL for LOAD DATA INFILEOFF  
ENABLED_PROFILINGWhether to enable query profiling codeON  
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_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_SQLBENCHDIRsql-bench directoryPREFIX  
INSTALL_SUPPORTFILESDIRExtra support files directoryPREFIX/support-files  
MYSQL_DATADIRData directory  
MYSQL_MAINTAINER_MODEWhether to enable MySQL maintainer-specific development environmentOFF  
MYSQL_PROJECT_NAMEWindows/Mac 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  
SYSCONFDIROption file directory  
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_EMBEDDED_SERVERWhether to build embedded serverOFF  
WITH_xxx_STORAGE_ENGINECompile storage engine xxx statically into server  
WITH_EXTRA_CHARSETSWhich extra character sets to includeall  
WITH_LIBWRAPWhether to include libwrap (TCP wrappers) supportOFF  
WITH_READLINEUse bundled readlineOFF 5.6.5
WITH_SSLType of SSL supportno  
WITH_UNIXODBCEnable unixODBC supportOFF  
WITH_ZLIBType of zlib supportsystem  
WITHOUT_xxx_STORAGE_ENGINEExclude storage engine xxx from build  


 

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
  • -DBUILD_CONFIG=mysql_release

    This option configures a source distribution with the same build options used by Oracle to produce binary distributions for official MySQL releases.

  • -DCMAKE_BUILD_TYPE=type

    The type of build to produce:

    • RelWithDebInfo: Enable optimizations and generate debugging information. This is the default MySQL build type.

    • 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.

  • -DCPACK_MONOLITHIC_INSTALL=bool

    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.

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.

  • -DCMAKE_INSTALL_PREFIX=dir_name

    The installation base directory.

    This value can be set at server startup with the --basedir option.

  • -DINSTALL_BINDIR=dir_name

    Where to install user programs.

  • -DINSTALL_DOCDIR=dir_name

    Where to install documentation.

  • -DINSTALL_DOCREADMEDIR=dir_name

    Where to install README files.

  • -DINSTALL_INCLUDEDIR=dir_name

    Where to install header files.

  • -DINSTALL_INFODIR=dir_name

    Where to install Info files.

  • -DINSTALL_LAYOUT=name

    Select a predefined installation layout:

    • STANDALONE: Same layout as used for .tar.gz and .zip packages. This is the default.

    • RPM: Layout similar to RPM packages.

    • SVR4: Solaris package layout.

    • DEB: DEB package layout (experimental).

    You can select a predefined layout but modify individual component installation locations by specifying other options. For example:

    shell> cmake . -DINSTALL_LAYOUT=SVR4 -DMYSQL_DATADIR=/var/mysql/data
    
  • -DINSTALL_LIBDIR=dir_name

    Where to install library files.

  • -DINSTALL_MANDIR=dir_name

    Where to install manual pages.

  • -DINSTALL_MYSQLSHAREDIR=dir_name

    Where to install shared data files.

  • -DINSTALL_MYSQLTESTDIR=dir_name

    Where to install the mysql-test directory.

  • -DINSTALL_PLUGINDIR=dir_name

    The location of the plugin directory.

    This value can be set at server startup with the --plugin_dir option.

  • -DINSTALL_SBINDIR=dir_name

    Where to install the mysqld server.

  • -DINSTALL_SCRIPTDIR=dir_name

    Where to install mysql_install_db.

  • -DINSTALL_SHAREDIR=dir_name

    Where to install aclocal/mysql.m4.

  • -DINSTALL_SQLBENCHDIR=dir_name

    Where to install the sql-bench directory. To not install this directory, use an empty value (-DINSTALL_SQLBENCHDIR=).

  • -DINSTALL_SUPPORTFILESDIR=dir_name

    Where to install extra support files.

  • -DMYSQL_DATADIR=dir_name

    The location of the MySQL data directory.

    This value can be set at server startup with the --datadir option.

  • -DSYSCONFDIR=dir_name

    The default my.cnf option file directory.

    This location cannot be set at server startup, but you can start the server with a given option file using the --defaults-file=file_name option, where file_name is the full path name to the file.

  • -DODBC_INCLUDES=dir_name

    The location of the ODBC includes directory, and may be used while configuring Connector/ODBC.

  • -DODBC_LIB_DIR=dir_name

    The location of the ODBC library directory, and may be used while configuring Connector/ODBC.

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), 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

To exclude a storage engine from the build, use -DWITHOUT_engine_STORAGE_ENGINE=1. 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
  • -DCOMPILATION_COMMENT=string

    A descriptive comment about the compilation environment.

  • -DDEFAULT_CHARSET=charset_name

    The server character set. By default, MySQL uses the latin1 (cp1252 West European) character set.

    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, utf8, utf8mb4, utf16, utf16le, utf32. The permissible character sets are listed in the cmake/character_sets.cmake file as the value of CHARSETS_AVAILABLE.

    This value can be set at server startup with the --character_set_server option.

  • -DDEFAULT_COLLATION=collation_name

    The server collation. By default, MySQL uses latin1_swedish_ci. Use the SHOW COLLATION statement to determine which collations are available for each character set.

    This value can be set at server startup with the --collation_server option.

  • -DENABLE_DEBUG_SYNC=bool

    Whether to compile the Debug Sync facility into the server. This facility is used for testing and debugging. This option is enabled by default, but has no effect unless MySQL is configured with debugging enabled. If debugging is enabled and you want to disable Debug Sync, use -DENABLE_DEBUG_SYNC=0.

    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.

    For a description of the Debug Sync facility and how to use synchronization points, see MySQL Internals: Test Synchronization.

  • -DENABLE_DOWNLOADS=bool

    Whether to download optional files. For example, with this option enabled, CMake downloads the Google Test distribution that is used by the test suite to run unit tests.

  • -DENABLE_DTRACE=bool

    Whether to include support for DTrace probes. For information about DTrace, wee Section 5.7, “Tracing mysqld Using DTrace”

  • -DENABLE_GCOV=bool

    Whether to include gcov support (Linux only).

  • -DENABLE_GPROF=bool

    Whether to enable gprof (optimized Linux builds only). This option was added in MySQL 5.6.6.

  • -DENABLED_LOCAL_INFILE=bool

    Whether to enable LOCAL capability in the client library for LOAD DATA INFILE.

    This option controls client-side LOCAL capability, but the capability can be set on the server side at server startup with the --local-infile option. See Section 6.1.6, “Security Issues with LOAD DATA LOCAL.

  • -DENABLED_PROFILING=bool

    Whether to enable query profiling code (for the SHOW PROFILE and SHOW PROFILES statements).

  • -DMYSQL_MAINTAINER_MODE=bool

    Whether to enable a MySQL maintainer-specific development environment. If enabled, this option causes compiler warnings to become errors.

  • -DMYSQL_PROJECT_NAME=name

    For Windows or Mac OS X, the project name to incorporate into the project file name. This option was added in MySQL 5.6.5.

  • -DMYSQL_TCP_PORT=port_num

    The port number on on which the server listens for TCP/IP connections. The default is 3306.

    This value can be set at server startup with the --port option.

  • -DMYSQL_UNIX_ADDR=file_name

    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.

    This value can be set at server startup with the --socket option.

  • -DWITH_DEBUG=bool

    Whether to include debugging support.

    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.

  • -DWITH_DEFAULT_COMPILER_OPTIONS=bool

    Whether to use the flags from cmake/build_configurations/compiler_options.cmake. This option was added in MySQL 5.6.6.

  • -DWITH_DEFAULT_FEATURE_SET=bool

    Whether to use the flags from cmake/build_configurations/feature_set.cmake. This option was added in MySQL 5.6.6.

  • -DWITH_EMBEDDED_SERVER=bool

    Whether to build the libmysqld embedded server library.

  • -DWITH_EXTRA_CHARSETS=name

    Which extra character sets to include:

    • all: All character sets. This is the default.

    • complex: Complex character sets.

    • none: No extra character sets.

  • -DWITH_LIBWRAP=bool

    Whether to include libwrap (TCP wrappers) support.

  • -DWITH_READLINE=bool

    Whether to use the readline library bundled with the distribution. This option was removed in MySQL 5.6.5 because readline is no longer bundled.

  • -DWITH_SSL=ssl_type

    The type of SSL support to include, if any:

    • no: No SSL support. This is the default before MySQL 5.6.6. As of 5.6.6, this is no longer a permitted value and the default is bundled.

    • yes: Use the system SSL library if present, else the library bundled with the distribution.

    • bundled: Use the SSL library bundled with the distribution. This is the default as of MySQL 5.6.6.

    • system: Use the system SSL library.

    • path_name: As of MySQL 5.6.7, it is permitted to specify the path name to the OpenSSL installation to use. This can be useful instead of a value of system when CMake detects an older or incorrect installed OpenSSL version. (Another permitted way to do the same thing is to set the CMAKE_PREFIX_PATH option to path_name.)

    For information about using SSL support, see Section 6.3.9, “Using SSL for Secure Connections”.

  • -DWITH_ZLIB=zlib_type

    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 indicates the source of zlib support:

    • bundled: Use the zlib library bundled with the distribution.

    • system: Use the system zlib library. This is the default.

  • -DWITH_UNIXODBC=1

    Enables unixODBC support, for Connector/ODBC.

Compiler Flags

To specify compiler flags, set the CFLAGS and CXXFLAGS environment variables before running CMake. Example:

shell> CFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
shell> CXXFLAGS=-DHAVE_EMBEDDED_PRIVILEGE_CONTROL
shell> export CFLAGS CXXFLAGS
shell> cmake [options]

The following flags control configuration features:

  • HAVE_EMBEDDED_PRIVILEGE_CONTROL

    By default, authentication for connections to the embedded server is disabled. To enable connection authentication, define this flag.

 

deepcar@ubuntu:~/Desktop$ apt-get apt 2.0.10 (arm64) Usage: apt-get [options] command apt-get [options] install|remove pkg1 [pkg2 ...] apt-get [options] source pkg1 [pkg2 ...] apt-get is a command line interface for retrieval of packages and information about them from authenticated sources and for installation, upgrade and removal of packages together with their dependencies. Most used commands: update - Retrieve new lists of packages upgrade - Perform an upgrade install - Install new packages (pkg is libc6 not libc6.deb) reinstall - Reinstall packages (pkg is libc6 not libc6.deb) remove - Remove packages purge - Remove packages and config files autoremove - Remove automatically all unused packages dist-upgrade - Distribution upgrade, see apt-get(8) dselect-upgrade - Follow dselect selections build-dep - Configure build-dependencies for source packages satisfy - Satisfy dependency strings clean - Erase downloaded archive files autoclean - Erase old downloaded archive files check - Verify that there are no broken dependencies source - Download source archives download - Download the binary package into the current directory changelog - Download and display the changelog for the given package See apt-get(8) for more information about the available commands. Configuration options and syntax is detailed in apt.conf(5). Information about how to configure sources can be found in sources.list(5). Package and version choices can be expressed via apt_preferences(5). Security details are available in apt-secure(8). This APT has Super Cow Powers.有什么问题
最新发布
03-09
<think>好的,我现在需要回答用户关于apt-get命令的详细用法和常用选项的问题。首先,我要确保自己正确理解apt-get的作用和它在Debian系Linux发行版中的重要性。根据提供的引用资料,apt-get是Debian和Ubuntu等系统的包管理工具,用于安装、更新、卸载软件包。 首先,我应该先介绍apt-get的基本概念,比如它是用来做什么的,适用的系统有哪些。引用3提到,apt-get适用于deb包管理式的操作系统,如Ubuntu,主要用于自动从软件仓库中管理软件。这一点需要在回答中明确说明。 接下来,用户需要了解常用选项。我需要整理常见的子命令,比如update、upgrade、install、remove、autoremove、purge、search、show等。每个子命令需要给出具体的用法示例,并解释其作用。例如,引用2和引用4提到了update和upgrade的使用,需要详细说明这两个命令的区别:update是更新软件包列表,而upgrade是升级已安装的软件包。 另外,用户可能对某些高级选项感兴趣,比如autoclean和clean的区别。根据引用4,autoclean会删除已过期的.deb文件,而clean则是删除所有已下载的安装包。这些细节需要解释清楚,以帮助用户理解如何管理存储空间。 还需要注意一些实用技巧,比如如何保持特定软件包的版本不被升级,这涉及到apt-mark hold命令,引用4提到这一点。这部分可以作为高级用法来介绍,帮助用户避免意外升级导致的问题。 此外,要确保回答符合用户提供的系统级指令,比如所有行内数学表达式用$...$,但这里可能用不到数学公式。需要检查是否有必要使用独立公式,但根据问题内容,可能不需要。回答结构要清晰,分点说明,每个子命令作为一个小标题,给出语法和示例。同时,在末尾生成相关问题,参考示例中的结构,问题要围绕apt-get的进阶使用、错误处理、与其他工具的比较等。 需要验证每个子命令的正确性,比如确保install和remove的语法正确,是否有可选的选项如-y来自动确认操作。同时,引用1提到当找不到apt-get命令时可能的问题,比如非Debian系系统,这点可以作为常见问题在相关提问中提及。 最后,确保引用标识正确添加,比如在提到更新软件包列表时引用2,介绍apt-get基本概念时引用3和4。保持回答自然,避免堆砌引用,而是在相关的地方注明来源。 总结步骤: 1. 介绍apt-get的基本概念和适用系统。 2. 列出常用子命令,每个命令的语法、说明和示例。 3. 高级选项和技巧,如保持包版本、清理存储。 4. 常见问题或注意事项。 5. 生成相关问题,引导用户深入学习。 需要确保所有信息准确,参考提供的引用资料,并且语言简洁明了,符合中文表达习惯。</think>### apt-get 命令详解及常用选项说明 `apt-get` 是 Debian 系 Linux 发行版(如 Ubuntu)的核心包管理工具,用于从软件仓库中**搜索、安装、升级、卸载**软件包[^3]。以下是其核心功能及常用选项说明: --- #### 一、常用子命令及语法 1. **更新软件包列表** ```bash sudo apt-get update ``` - **作用**:同步远程仓库的软件包信息到本地(需在修改软件源或安装新包前执行)[^2]。 - **示例**:定期运行以确保本地列表最新。 2. **升级已安装的软件包** ```bash sudo apt-get upgrade ``` - **作用**:基于当前软件包列表,升级所有可更新的包(不处理依赖冲突或删除旧包)。 - **扩展**:使用 `sudo apt-get dist-upgrade` 可智能处理依赖关系并升级系统版本。 3. **安装指定软件包** ```bash sudo apt-get install <package_name> ``` - **选项**:添加 `-y` 可自动确认操作(如 `sudo apt-get install -y nginx`)。 - **示例**:安装多个包时用空格分隔,如 `sudo apt-get install git curl`。 4. **卸载软件包** ```bash sudo apt-get remove <package_name> # 卸载但保留配置文件 sudo apt-get purge <package_name> # 卸载并删除配置文件[^4] ``` - **区别**:`purge` 适用于彻底清理,例如 `sudo apt-get purge mysql-server`。 5. **自动清理无用包** ```bash sudo apt-get autoremove # 删除因依赖而安装、但不再需要的包 sudo apt-get autoclean # 删除已过期的.deb缓存文件 sudo apt-get clean # 删除所有已下载的.deb文件 ``` 6. **搜索软件包** ```bash apt-cache search <keyword> # 根据关键词搜索包(如 apt-cache search "python editor") ``` --- #### 二、高级技巧 1. **锁定软件包版本** ```bash sudo apt-mark hold <package_name> # 阻止特定包更新[^4] sudo apt-mark unhold <package_name> # 解除锁定 ``` - **场景**:防止关键服务(如数据库)因意外升级导致兼容性问题。 2. **查看软件包详情** ```bash apt-cache show <package_name> # 显示包的版本、依赖、描述等信息 ``` --- #### 三、注意事项 - **权限要求**:所有修改系统的操作(如安装、卸载)需加 `sudo`。 - **错误处理**:若提示 `apt-get command not found`,可能是系统非 Debian 系(如 CentOS 使用 `yum`)[^1]。 - **依赖冲突**:若升级失败,可尝试 `sudo apt-get -f install` 修复依赖。 --- §§ 相关问题 §§ 1. 如何解决 `apt-get install` 时的依赖冲突问题? 2. `apt` 和 `apt-get` 命令有何区别? 3. 如何添加第三方软件源并安装非官方软件包? 4. 如何通过 `apt-get` 回滚误升级的软件版本? [^1]: 引用1 : 引用2 : 引用3 : 引用4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值