Centos 8.3 源码编译安装 mysql 8.0.24

一、下载mysql 源码包。

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.24.tar.gz

二、解压源码包

tar zxvf mysql-boost-8.0.24.tar.gz
cd mysql-8.0.24

三、安装依赖程序

yum install -y libaio bison ncurses-devel m4 openssl-devel gcc gcc-c++

如果提示:

-- Running cmake version 3.11.4
-- Could NOT find Git (missing: GIT_EXECUTABLE)

则需要安装git

yum install git

四、编译mysql的命令

cmake -DCMAKE_INSTALL_PREFIX=/home/gskernel_a/mysql/output -DBUILD_CONFIG=mysql_release  -DWITH_UNIT_TESTS=0 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/gskernel_a/mysql/mysql-8.0.24/boost

根据实际路径。选择你的路径。

错误提示

-- Running cmake version 3.11.4
-- Found Git: /usr/bin/git (found version "2.27.0") 
-- This is .el8. as found from 'rpm -qf /'
-- Looking for a devtoolset compiler
CMake Warning at CMakeLists.txt:280 (MESSAGE):
  Could not find devtoolset compiler in /opt/rh/gcc-toolset-10


CMake Error at CMakeLists.txt:281 (MESSAGE):
  Please set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.


-- Configuring incomplete, errors occurred!

遇到上面的错误提示。cmake的命令可以根据gcc和g++的位置

 

cmake -DCMAKE_INSTALL_PREFIX=/home/gskernel_a/mysql/output -DBUILD_CONFIG=mysql_release  -DWITH_UNIT_TESTS=0 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/gskernel_a/mysql/mysql-8.0.24/boost -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++

遇到错误

-- Running cmake version 3.11.4
-- CMAKE_MODULE_PATH is /home/gskernel_a/mysql/mysql-8.0.24/cmake
-- MySQL 8.0.24
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Source directory /home/gskernel_a/mysql/mysql-8.0.24
-- Binary directory /home/gskernel_a/mysql/mysql-8.0.24
CMake Error at CMakeLists.txt:382 (MESSAGE):
  Please do not build in-source.  Out-of source builds are highly
  recommended: you can have multiple builds for the same source, and there is
  an easy way to do cleanup, simply remove the build directory (note that
  'make clean' or 'make distclean' does *not* work)

  You *can* force in-source build by invoking cmake with
  -DFORCE_INSOURCE_BUILD=1


-- Configuring incomplete, errors occurred!
See also "/home/gskernel_a/mysql/mysql-8.0.24/CMakeFiles/CMakeOutput.log".

上面说的很清楚。添加这个宏 -DFORCE_INSOURCE_BUILD=1

然后继续编译


-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -ffunction-sections -fdata-sections -O2 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -ffunction-sections -fdata-sections -Os -DNDEBUG
-- CMAKE_C_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections
-- CMAKE_CXX_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections
-- CMAKE_EXE_LINKER_FLAGS 
-- CMAKE_MODULE_LINKER_FLAGS 
-- CMAKE_SHARED_LINKER_FLAGS 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gskernel_a/mysql/mysql-8.0.24

出现下面两个,就证明cmake成功了。下面要make 然后就是make install
-- Configuring done
-- Generating done

 

然后在你设置的目标路径下的lib文件夹下就可以看到libmysqlclient.so

 

关于mysql8 cmake 的编译选项参考如下

https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html

 

五、在Centos7.6上源码编译安装mysql8.0

如果在centos 7.6机器上编译mysql8.0 则会提示错误

-- Running cmake version 2.8.12.2
CMake Warning at CMakeLists.txt:82 (MESSAGE):
  Please use cmake3 rather than cmake on this platform


-- Please install cmake3 (yum install cmake3)
CMake Error at CMakeLists.txt:112 (CMAKE_MINIMUM_REQUIRED):
  CMake 3.5.1 or higher is required.  You are running version 2.8.12.2


-- Configuring incomplete, errors occurred!

则需要源码安装cmake3.5.1+

cmake不要升级到最新。 3.5.1版本即可。因为3.20版本编译mysql8.0 会报各种错误

 

 

-- CMAKE_GENERATOR: Unix Makefiles
CMake Error at cmake/os/Linux.cmake:76 (MESSAGE):
  GCC 5.3 or newer is required (-dumpversion says 4.8.5)
Call Stack (most recent call first):
  CMakeLists.txt:491 (INCLUDE)

gcc 版本也是需要升级

 

gcc 源码编译的时候。提示需要依赖其他版本

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

安装gcc详细参考 https://www.jianshu.com/p/444169a3721a

但是注意其中一个变化:isl编译已经将--with-gmp改为--with-gmp-prefix

 

-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -ffunction-sections -fdata-sections -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -ffunction-sections -fdata-sections -Os -DNDEBUG
-- CMAKE_C_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections
-- CMAKE_CXX_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections
-- CMAKE_EXE_LINKER_FLAGS
-- CMAKE_MODULE_LINKER_FLAGS
-- CMAKE_SHARED_LINKER_FLAGS
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mysql/mysql-8.0.24

 

/home/mysql/cmake35output/bin/cmake -DCMAKE_INSTALL_PREFIX=/home/mysql/output -DBUILD_CONFIG=mysql_release  -DWITH_UNIT_TESTS=0 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/mysql/mysql-8.0.24/boost -DCMAKE_C_COMPILER=/usr/local/gcc-8.2.0/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-8.2.0/bin/g++ -DFORCE_INSOURCE_BUILD=1

 

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值