MySQL has been using the CMake compilation tool since version 5.5, so it is normal that you cannot find the configure file in the installation source files. Many people downloaded the new version of MySQL because they couldn't find the configure file and didn't know how to continue. Is there an article for reference? In fact , there is an article on the http://forge.mysql.com website, which specifically introduces how to use the CMake tool to compile and install the new version of MySQL.
The original address is: http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide .
2. Command calling syntax
3. Installation parameter option
4. Storage engine option
5. Library file loading option
6. Other options
introduce
This page will introduce some configuration options of common compilation tools and how these configuration options are configured in CMake, and then introduce how to use CMake tools to build and compile MySQL.
command call syntax
The following table lists the calling syntax and equivalent CMake commands for common compilation tools. "." represents your current working directory path, please replace the path "." appropriately according to the directory you are in.
configure command | CMake commands |
./configure | cmake . |
./configure --help | cmake . -LH or ccmake . |
Before reconfiguring or rebuilding, you need to clear old object files and cache information as follows:
Autotools:
- make clean
- rm config.cache
CMake (Unix/Linux):
- make clean
- rm CMakeCache.txt
CMake (Windows):
- devenv MySQL.sln /clean
- del CMakeCache.txt
Installation parameter options
In the following table, the value of "CMAKE_INSTALL_PREFIX" represents the installation root directory, and the paths of other parameter values are relative to the root directory. Of course, you can also use the absolute path directly, as follows:
Parameter value description | configuration options | CMak option |
install root directory | --prefix=/usr | -DCMAKE_INSTALL_PREFIX=/usr |
mysqld directory | --libexecdir=/usr/sbin | -DINSTALL_SBINDIR = sbin |
data storage directory | --localstatedir=/var/lib/mysql | -DMYSQL_DATADIR=/var/lib/mysql |
Configuration file (my.cnf) directory | --sysconfdir=/etc/mysql | -DSYSCONFDIR=/etc/mysql |
plugin directory | --with-plugindir=/usr/lib64/mysql/plugin | -DINSTALL_PLUGINDIR=lib64/mysql/plugin |
Manual file directory | --mandir=/usr/share/man | -DINSTALL_MANDIR = share / man |
shared data directory | --sharedstatedir=/usr/share/mysql | -DINSTALL_SHAREDIR=share |
Library library directory | --libdir=/usr/lib64/mysql | -DINSTALL_LIBDIR = lib64 / mysql |
Header installation directory | --includedir=/usr/include/mysql | -DINSTALL_INCLUDEDIR=include/mysql |
Directory of Information Documents | --infodir=/usr/share/info | -DINSTALL_INFODIR=share/info |
storage engine options
The storage engine exists in the form of a plug-in, so this option can control the construction of the plug-in, such as specifying the use of a specific engine.
--with-plugins配置选项接受两种形式的参数值,它没有对应的CMake配置参数:
① 以逗号(,)分隔的引擎名称列表;
② a "group name" value that is shorthand for a set of engines
在CMake中,引擎被作为单个的选项来进行控制。假设有以下配置选项:
- --with-plugins=csv,myisam,myisammrg,heap,innobase,archive,blackhole
上面的参数指定MySQL数据库可以支持哪些数据库引擎,将上述编译选项转换成CMake编译选项时,下面的几个引擎名字可以被省略,因为编译时,默认就支持:
- csv myisam myisammrg heap
然后使用下面的编译参数,以启用InnoDB、ARCHIVE和BLACKHOLE引擎支持:
- -DWITH_INNOBASE_STORAGE_ENGINE=1
- -DWITH_ARCHIVE_STORAGE_ENGINE=1
- -DWITH_BLACKHOLE_STORAGE_ENGINE=1
当然也可以使用“ON”来替代数字1,它们是等效的。
如果你想除去对某种引擎的支持,则在CMake编译选项中使用-DWITHOUT_<ENGINE>_STORAGE_ENGINE,例如:
- -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
- -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
- -DWITHOUT_PARTITION_STORAGE_ENGINE=1
库文件加载选项
该选项指明Mysql使用库的情况:
参数值说明 | 配置选项 | CMak选项 |
readline库 | --with-readline | -DWITH_READLINE=1 |
SSL库 | --with-ssl=/usr | -DWITH_SSL=system |
zlib库 | --with-zlib-dir=/usr | -DWITH_ZLIB=system |
libwrap库 | --without-libwrap | -DWITH_LIBWRAP=0 |
其他选项
CMake编译选项支持大部分之前版本的MySQL编译选项,新老编译选项的差别在于:之前的是小写,现在全部变成了大写,之前采用双横线,现在使用单横线,之前使用的破折号,现在取而代之的是使用下划线,例如:
- --with-debug => WITH_DEBUG=1
- --with-embedded-server => WITH_EMBEDDED_SERVER
下面是编译MySQL的新老参数对照表:
参数值说明 | 配置选项 | CMak选项 |
TCP/IP端口 | --with-tcp-port-=3306 | -DMYSQL_TCP_PORT=3306 |
UNIX socket文件 | --with-unix-socket-path=/tmp/mysqld.sock | -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock |
启用加载本地数据 | --enable-local-infile | -DENABLED_LOCAL_INFILE=1 |
扩展字符支持 | --with-extra-charsets=all(默认:all) | -DEXTRA_CHARSETS=all(默认:all) |
默认字符集 | --with-charset=utf8 | -DDEFAULT_CHARSET=utf8 |
默认字符校对 | --with-collation=utf8_general_ci | -DDEFAULT_COLLATION=utf8_general_ci |
Build the server | --with-server | 无 |
嵌入式服务器 | --with-embedded-server | -DWITH_EMBEDDED_SERVER=1 |
libmysqld权限控制 | --with-embedded-privilege-control | 无 |
安装文档 | --without-docs | 无 |
Big tables支持 | --with-big-tables, --without-big-tables | 无 |
mysqld运行用户 | --with-mysqld-user=mysql | -DMYSQL_USER=mysql |
调试模式 | --without-debug(默认禁用) | -DWITH_DEBUG=0(默认禁用) |
GIS支持 | --with-geometry | 无 |
社区功能 | --enable-community-features | 无 |
Profiling | --disable-profiling(默认启用) | -DENABLE_PROFILING=0(默认启用) |
pstack | --without-pstack | 无(新版移除该功能) |
汇编字符串函数 | --enable-assembler | 无 |
构建类型 | --build=x86_64-pc-linux-gnu | 没有等效参数 |
交叉编译主机 | --host=x86_64-pc-linux-gnu | 没有等效参数 |
客户端标志 | --with-client-ldflags=-lstdc++ | 无 |
线程安全标志 | --enable-thread-safe-client | 无 |
注释存储类型 | --with-comment='string' | -DWITH_COMMENT='string' |
Shared/static binaries | --enable-shared --enable-static | 无 |
内存使用控制 | --with-low-memory | 无 |