环境及版本
本文档使用的系统信息
cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
数据库版本
5.7
安装依赖
安装make 编译器(一般linux自带已经有了)
下载地址:http://www.gun.org/software/make/
tar zxvf make-3.82.tar.gz
cd make-3.82
./configure
make
make install
安装bison
下载地址:http://www.gnu.org/software/bison/
或者:https://ftp.gnu.org/gnu/bison/
tar zxvf bison-3.8.tar.gz
cd bison-3.8
./configure
make
make install
----如果configure时候报m4错误,先安装m4:https://www.gnu.org/software/m4/
安装cmake
下载地址:http://www.cmake.org
tar zxvf cmake-3.24.0.tar.gz
cd cmake-3.24.0
./configure
make
make install
---视情况,安装yum install gcc gcc-c++
安装mysql 源码需要的库
ncurses库
https://invisible-island.net/ncurses/announce.html
下载:https://ftp.gnu.org/gnu/ncurses/
yum install ncurses-devel
boost c++库安装,编译时用到
下载:https://www.boost.org/
参考:http://t.zoukankan.com/sigma0--p-12630497.html
tar -xzf boost_1_59_0.tar.gz
cd boost_1_59_0/
./bootstrap.sh ==>生成安装工具bjam和b2
./b2 install
ssl库
版本符合要求:
OpenSSL 1.0.1 or higher https://dev.mysql.com/doc/refman/5.7/en/source-ssl-library-configuration.html
下载:https://www.openssl.org/source/
yum install openssl-libs
make的时候遇到libedit版本问题
https://dev.mysql.com/worklog/task/?id=13534
下载包,安装
开始安装MySQL
下载地址:http://dev.mysql.com/, 解压并安装MySQL
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
mkdir bld
cd bld
cmake .. \
-DCMAKE_INSTALL_PREFIX=/rootl/mysql \
-DINSTALL_DATADIR=/root/mysql/data -DWITH_EDITLINE=system
make
sudo make install
cmake .. -DCMAKE_INSTALL_PREFIX=/rootl/mysql -DINSTALL_DATADIR=/dingliang/data/mysql/data -DWITH_EDITLINE=system
注意1:执行cmake 命令时,反斜杠后面不能有空格。
注意2:cmake option参考:https://dev.mysql.com/doc/internals/en/packager-friendly-build-options.html
注意2:重新编译,make clean, 先删除CMakeCache.txt
make报错:
可能会遇到的报错信息。
Failed to parse input file /dingliang/data/mysql-server/sql/share/errmsg-utf8.txt
make[2]: *** [include/mysqld_error.h] Error 1
make[1]: *** [extra/CMakeFiles/GenError.dir/all] Error 2
make: *** [all] Error 2
参考文档
http://mingxinglai.com/cn/2013/06/compile-mysql-in-linux/
https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/installing-source-distribution.html
https://dev.mysql.com/doc/refman/8.0/en/source-installation-prerequisites.html
https://dev.mysql.com/doc/internals/en/cmake-prerequisites.html
https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html