CentOS 8.2.2004 环境 cmake安装方式编译MySQL8.0.22(Cmake3.19.1)

CentOS 8.2.2004 环境 cmake安装方式编译MySQL8.0.22(Cmake3.19.1)入坑手册

环境:

[root@mysql-server ~]# hostnamectl
   Static hostname: mysql-server
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f52b3df75ceb40e59f47b28ef6c1ecd4
           Boot ID: fd42163b44314848a4d2a40bad8a5e0f
    Virtualization: kvm
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-193.el8.x86_64
      Architecture: x86-64
[root@mysql-server ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@mysql-server ~]#

一、依赖关系

dnf install -y 
gcc gcc-c++ 
ncurses-libs 
ncurses-devel 
perl  bison 
ncurses 
libaio-devel 
openssl-devel 
ncurses-compat-libs 
libtirpc-devel

二、下载文安装文件

# 安装 wget vim 
dnf -y install vim wget
# 下载MySql8.0.22 的源码包
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.22.tar.gz
# 下载cmake3.19.1源码包
wget https://cmake.org/files/v3.19/cmake-3.19.1.tar.gz
# 下载boost 库
wget https://phoenixnap.dl.sourceforge.net/project/boost/boost/1.73.0/boost_1_73_0.tar.gz
下载速度慢的小朋友可以开启超人模式
# 神秘代码如下:
vim /etc/profile  
# 加入以下代码:
proxy=socks5://192.168.xxx.xxx:10808   #需要自己准备神秘服务器,没有服务器请耐心等待
source /etc/profile   # 立即生效

验证下载文件体积,先解压安装cmake

[root@mysql-server ~]# ll -h
total 286M
-rw-------. 1 root root 1.3K Dec  7 07:24 anaconda-ks.cfg
-rw-r--r--. 1 root root 8.9M Dec  7 07:52 cmake-3.19.1.tar.gz
-rw-r--r--. 1 root root 277M Dec  7 07:52 mysql-8.0.22.tar.gz
[root@mysql-server ~]#
[root@mysql-server ~]# tar -zxvf cmake-3.19.1.tar.gz
[root@mysql-server ~]# ls
anaconda-ks.cfg  cmake-3.19.1  cmake-3.19.1.tar.gz  mysql-8.0.22.tar.gz

仔细查看README.txt 有安装过程

[root@mysql-server cmake-3.19.1]# ls
Auxiliary         CMakeCPackOptions.cmake.in  CMakeLogo.gif             configure         CTestConfig.cmake    doxygen.config  Modules     Source     Utilities
bootstrap         CMakeGraphVizOptions.cmake cmake_uninstall.cmake.in  CONTRIBUTING.rst  CTestCustom.cmake.in  Help            Packaging   Templates
CMakeCPack.cmake CMakeLists.txt              CompileFlags.cmake       Copyright.txt     DartConfig.cmake     Licenses        README.rst  Tests

[root@mysql-server cmake-3.19.1]# ./bootstrap
---------------------------------------------
Cmake 3.19.1, Copyright 2000-2020 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
# 此处略省几十万字##############################################
-- Checking for curses support
-- Checking for curses support - Success
-- Looking for wsyncup in /usr/lib64/libcurses.so
-- Looking for wsyncup in /usr/lib64/libcurses.so - found
-- Looking for cbreak in /usr/lib64/libncurses.so
-- Looking for cbreak in /usr/lib64/libncurses.so - found
-- Looking for nodelay in /usr/lib64/libncurses.so
-- Looking for nodelay in /usr/lib64/libncurses.so - found
-- Found Curses: /usr/lib64/libncurses.so
-- Looking for elf.h
-- Looking for elf.h - found
-- Looking for use_default_colors
-- Looking for use_default_colors - found
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - NOTFOUND
-- Performing Test run_pic_test
-- Performing Test run_pic_test - Success
-- Performing Test run_inlines_hidden_test
-- Performing Test run_inlines_hidden_test - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-3.19.1
---------------------------------------------
Cmake has bootstrapped.  Now run gmake.
# 看到这里就算是成功了一半
[root@mysql-server cmake-3.19.1]# make -j 256 && make install #这一步大家不要学我
-- Installing: /usr/local/share/cmake-3.19/Templates/Windows/Windows_TemporaryKey.pfx
-- Installing: /usr/local/share/vim/vimfiles/indent
-- Installing: /usr/local/share/vim/vimfiles/indent/cmake.vim
-- Installing: /usr/local/share/vim/vimfiles/syntax
-- Installing: /usr/local/share/vim/vimfiles/syntax/cmake.vim
-- Installing: /usr/local/share/emacs/site-lisp/cmake-mode.el
-- Installing: /usr/local/share/aclocal/cmake.m4
-- Installing: /usr/local/share/bash-completion/completions/cmake
-- Installing: /usr/local/share/bash-completion/completions/cpack
-- Installing: /usr/local/share/bash-completion/completions/ctest
[root@mysql-server cmake-3.19.1]#

配置boost

[root@mysql-server ~]# tar -zxvf boost_1_73_0.tar.gz
[root@mysql-server ~]# mv boost_1_73_0 /usr/local/boost

为MySQL添加不可登录的用户组

groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
[root@mysql-server ~]# groupadd mysql
[root@mysql-server ~]# useradd -M -s /sbin/nologin mysql -g mysql

创建数据库目录

mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
[root@mysql-server ~]# mkdir -p /data/mysql
[root@mysql-server ~]# chown -R mysql:mysql /data/mysql

———————————上半部分为环境与Cmake 准备过程————————————

安装完cmke 继续解压MySQL8.0.22.tar.gz

[root@mysql-server ~]# tar -zxvf mysql-8.0.22.tar.gz
[root@mysql-server ~]# cd mysql-8.0.22/
[root@mysql-server mysql-8.0.22]# ll
total 708
drwxr-xr-x.  2 root root       6 Dec  7 08:18 build
drwxr-xr-x.  7 7161 31415   4096 Sep 23 09:04 client
drwxr-xr-x.  4 7161 31415   4096 Sep 23 09:04 cmake
-rw-r--r--.  1 7161 31415  64796 Sep 23 08:37 CMakeLists.txt
drwxr-xr-x. 12 7161 31415    204 Sep 23 09:04 components
-rw-r--r--.  1 7161 31415  10220 Sep 23 08:37 config.h.cmake
-rw-r--r--.  1 7161 31415  21998 Sep 23 08:37 configure.cmake
drwxr-xr-x.  2 7161 31415     82 Sep 23 09:04 Docs
-rw-r--r--.  1 7161 31415   2361 Sep 23 08:37 Doxyfile-ignored
-rw-r--r--.  1 7161 31415 117742 Sep 23 08:37 Doxyfile.in
drwxr-xr-x.  3 7161 31415    124 Sep 23 09:04 doxygen_resources
drwxr-xr-x. 11 7161 31415    155 Sep 23 09:04 extra
drwxr-xr-x.  4 7161 31415   4096 Sep 23 09:04 include
-rw-r--r--.  1 7161 31415    333 Sep 23 08:37 INSTALL
drwxr-xr-x.  5 7161 31415    112 Sep 23 09:04 libbinlogevents
drwxr-xr-x.  3 7161 31415     39 Sep 23 09:04 libbinlogstandalone
drwxr-xr-x.  4 7161 31415   4096 Sep 23 09:04 libmysql
drwxr-xr-x.  2 7161 31415   4096 Sep 23 09:04 libservices
-rw-r--r--.  1 7161 31415 378912 Sep 23 08:37 LICENSE
drwxr-xr-x.  2 7161 31415   4096 Sep 23 09:04 man
drwxr-xr-x. 10 7161 31415   4096 Sep 23 09:04 mysql-test
-rw-r--r--.  1 7161 31415     88 Sep 23 08:37 MYSQL_VERSION
drwxr-xr-x.  2 7161 31415   4096 Sep 23 09:04 mysys
drwxr-xr-x. 10 7161 31415    131 Sep 23 09:04 packaging
drwxr-xr-x. 24 7161 31415   4096 Sep 23 09:04 plugin
-rw-r--r--.  1 7161 31415    687 Sep 23 08:37 README
drwxr-xr-x.  6 7161 31415    138 Sep 23 09:04 router
-rw-r--r--.  1 7161 31415   4698 Sep 23 08:37 run_doxygen.cmake
drwxr-xr-x.  4 7161 31415   4096 Sep 23 09:04 scripts
drwxr-xr-x.  3 7161 31415    155 Sep 23 09:04 share
drwxr-xr-x.  2 7161 31415      6 Sep 23 09:04 source_downloads
drwxr-xr-x. 14 7161 31415  24576 Sep 23 09:05 sql
drwxr-xr-x.  2 7161 31415   4096 Sep 23 09:04 sql-common
drwxr-xr-x. 15 7161 31415    215 Sep 23 09:04 storage
drwxr-xr-x.  3 7161 31415   4096 Sep 23 09:04 strings
drwxr-xr-x.  2 7161 31415    202 Sep 23 09:04 support-files
drwxr-xr-x.  2 7161 31415    101 Sep 23 09:04 testclients
drwxr-xr-x.  5 7161 31415     70 Sep 23 09:04 unittest
drwxr-xr-x.  2 7161 31415    271 Sep 23 09:04 utilities
drwxr-xr-x.  2 7161 31415   4096 Sep 23 09:04 vio
[root@mysql-server mysql-8.0.22]# mkdir build
[root@mysql-server mysql-8.0.22]# cd build/
[root@mysql-server build]#

cmake编译安装

cmake .. 
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql  
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock  
-DMYSQL_DATADIR=/data/mysql 
-DSYSCONFDIR=/etc 
-DMYSQL_TCP_PORT=3306 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1  
-DWITH_MYISAM_STORAGE_ENGINE=1 
-DWITH_BOOST=/usr/local/boost 
-DENABLED_LOCAL_INFILE=1 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci  
-DWITH_DEBUG=0 
-DMYSQL_USER=mysql 
-DWITH_XTRADB_STORAGE_ENGINE=1 
-DWITH_PARTITION_STORAGE_ENGINE=1  
-DWITH_READLINE=1 
-DWITH_EXTRA_CHARSETS=1 
-DEXTRA_CHARSETS=all 
-DWITH_BIG_TABLES=1 

输入对话框然后长这样:

[root@mysql-server build]# cmake .. 
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  
> -DMYSQL_DATADIR=/data/mysql 
> -DSYSCONFDIR=/etc 
> -DMYSQL_TCP_PORT=3306 
> -DWITH_INNOBASE_STORAGE_ENGINE=1 
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1  
-DWITH_BOOST=/usr/local/boost 
> -DWITH_MYISAM_STORAGE_ENGINE=1 
> -DWITH_BOOST=/usr/local/boost 
> -DENABLED_LOCAL_INFILE=1 
> -DDEFAULT_CHARSET=utf8 
> -DDEFAULT_COLLATION=utf8_general_ci  
> -DWITH_DEBUG=0 
> -DMYSQL_USER=mysql 
> -DWITH_XTRADB_STORAGE_ENGINE=1 
> -DWITH_PARTITION_STORAGE_ENGINE=1  
> -DWITH_READLINE=1 
> -DWITH_EXTRA_CHARSETS=1 
> -DEXTRA_CHARSETS=all 
> -DWITH_BIG_TABLES=1

MySQL8.0.22需要boost_1_73_0的支持,以下是某次编译过程中使用boost_1_74_0,具体如下:

-- Packaging as: mysql-8.0.22-Linux-x86_64
-- Performing Test C_LD_LLD_RESULT
-- Performing Test C_LD_LLD_RESULT - Failed
-- Performing Test CXX_LD_LLD_RESULT
-- Performing Test CXX_LD_LLD_RESULT - Failed
-- Performing Test C_LD_GOLD_RESULT
-- Performing Test C_LD_GOLD_RESULT - Success
-- Performing Test CXX_LD_GOLD_RESULT
-- Performing Test CXX_LD_GOLD_RESULT - Success
-- Local boost dir /usr/local/boost
-- Found /usr/local/boost/boost/version.hpp
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 107000
Cmake Warning at cmake/boost.cmake:304 (MESSAGE):
  Boost minor version found is 70 we need 73
Call Stack (most recent call first):
  CMakeLists.txt:1146 (INCLUDE)


-- BOOST_INCLUDE_DIR /usr/local/boost
-- LOCAL_BOOST_DIR /usr/local/boost
-- LOCAL_BOOST_ZIP LOCAL_BOOST_ZIP-NOTFOUND
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_73_0

Cmake Error at cmake/boost.cmake:107 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This Cmake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  You can also download boost manually, from
  https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz

  If you are inside a firewall, you may need to use an https proxy:

  export https_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:307 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:1146 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/root/mysql-8.0.22/build/CMakeFiles/CMakeOutput.log".
See also "/root/mysql-8.0.22/build/CMakeFiles/CMakeError.log".
[root@mysql-server build]# wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz
[root@mysql-server build]# tar -zxvf 1.73.0/source/boost_1_73_0.tar.gz
[root@mysql-server build]# rm -rf /usr/local/boost
[root@mysql-server build]# mv boost_1_73_0 /usr/local/boost

编译出现问题

-- Checking for module 'libtirpc'
--   Found libtirpc, version 1.1.4
-- Performing Test HAVE_XDR_OPS_X_PUTINT32
-- Performing Test HAVE_XDR_OPS_X_PUTINT32 - Failed
-- Performing Test HAVE_XDR_OPS_X_GETINT32
-- Performing Test HAVE_XDR_OPS_X_GETINT32 - Failed
-- Performing Test HAVE_RPC_INLINE_T
-- Performing Test HAVE_RPC_INLINE_T - Success
-- Performing Test OLD_XDR
-- Performing Test OLD_XDR - Failed
-- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES
-- Performing Test HAS_INCOMPATIBLE_POINTER_TYPES - Success
-- Performing Test X_PUTLONG_NOT_USE_CONST
-- Performing Test X_PUTLONG_NOT_USE_CONST - Failed
Cmake Error at plugin/group_replication/libmysqlgcs/cmake/rpcgen.cmake:104 (MESSAGE):
  Could not find rpcgen
Call Stack (most recent call first):
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:53 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/root/mysql-8.0.22/build/CMakeFiles/CMakeOutput.log".
See also "/root/mysql-8.0.22/build/CMakeFiles/CMakeError.log".
[root@mysql-server build]#

缺少rpcgen

发布地址:https://github.com/thkukuk/rpcsvc-proto/releases/tag/v1.4.2
[root@mysql-server rpcsvc-proto-1.4.2]# xz -d rpcsvc-proto-1.4.2.tar.xz
[root@mysql-server rpcsvc-proto-1.4.2]# tar -xf rpcsvc-proto-1.4.2.tar
[root@mysql-server rpcsvc-proto-1.4.2]# cd rpcsvc-proto-1.4.2/
[root@mysql-server rpcsvc-proto-1.4.2]# ls
ABOUT-NLS   AUTHORS    compile       config.h.in   config.sub  configure.ac  depcomp  install-sh  Makefile.am  missing  po      rpcgen  THANKS
aclocal.m4  ChangeLog  config.guess  config.rpath  configure   COPYING       INSTALL  m4          Makefile.in  NEWS     README  rpcsvc
[root@mysql-server rpcsvc-proto-1.4.2]# ./configure && make && make install

接着上面的Cmake

-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;RAPIDJSON_NO_SIZETYPEDEFINE;RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0;RAPIDJSON_SCHEMA_USE_STDREGEX=1;HAVE_CONFIG_H;__STDC_LIMIT_MACROS;__STDC_FORMAT_MACROS;_USE_MATH_DEFINES;LZ4_DISABLE_DEPRECATE_WARNINGS;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wjump-misses-init -Wstringop-truncation
-- CMAKE_CXX_FLAGS: -std=c++14 -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wlogical-op
-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -DDBUG_OFF -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -DDBUG_OFF -ffunction-sections -fdata-sections -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -DDBUG_OFF -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
Cmake Warning:
  Manually-specified variables were not used by the project:

    EXTRA_CHARSETS
    MYSQL_USER
    WITH_BIG_TABLES
    WITH_PARTITION_STORAGE_ENGINE
    WITH_READLINE
    WITH_XTRADB_STORAGE_ENGINE

MySQL 8.0.22 不支持这六条功能,我们需要手动删除参数,并且重新编译

代码修改后如下:

cmake .. 
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql  
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock  
-DMYSQL_DATADIR=/data/mysql 
-DSYSCONFDIR=/etc 
-DMYSQL_TCP_PORT=3306 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1  
-DWITH_MYISAM_STORAGE_ENGINE=1 
-DWITH_BOOST=/usr/local/boost 
-DENABLED_LOCAL_INFILE=1 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci  
-DWITH_DEBUG=0 
-DWITH_EXTRA_CHARSETS=1 

下面六条是不用的

    -DWITH_PARTITION_STORAGE_ENGINE=1  
    -DMYSQL_USER=mysql 
    -DEXTRA_CHARSETS=all 
    -DWITH_BIG_TABLES=1 
    -DWITH_READLINE=1 
    -DWITH_XTRADB_STORAGE_ENGINE=1 

遇关键错误

-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;RAPIDJSON_NO_SIZETYPEDEFINE;RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0;RAPIDJSON_SCHEMA_USE_STDREGEX=1;HAVE_CONFIG_H;__STDC_LIMIT_MACROS;__STDC_FORMAT_MACROS;_USE_MATH_DEFINES;LZ4_DISABLE_DEPRECATE_WARNINGS;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wjump-misses-init -Wstringop-truncation
-- CMAKE_CXX_FLAGS: -std=c++14 -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wlogical-op
-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -DDBUG_OFF -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -DDBUG_OFF -ffunction-sections -fdata-sections -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -DDBUG_OFF -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: /root/mysql-8.0.22/build
[root@mysql-server build]# dnf -y isntall doxygen
No such command: isntall. Please use /usr/bin/dnf --help
It could be a DNF plugin command, try: "dnf install 'dnf-command(isntall)'"
[root@mysql-server build]# dnf -y install doxygen
Last metadata expiration check: 1:09:23 ago on Mon 07 Dec 2020 07:37:21 AM EST.
No match for argument: doxygen
Error: Unable to find a match: doxygen

解决doxygen

发布地址:https://github.com/doxygen/doxygen
[root@mysql-server build]# git clone https://github.com/doxygen/doxygen.git
[root@mysql-server build]# cd doxygen
[root@mysql-server build]# mkdir build
[root@mysql-server build]# cd build
[root@mysql-server build]# cmake -G "Unix Makefiles" ..
[root@mysql-server build]# make

编译doxygen报错,

[root@mysql-server build]# cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Cmake Error at /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:577 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.19/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:103 (find_package)

源码编译Python 3.9

发布地址:https://www.python.org/
[root@mysql-server ~]# wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
[root@mysql-server ~]# tar -zxvf Python-3.9.0.tgz
[root@mysql-server ~]# cd Python-3.9.0/
[root@mysql-server Python-3.9.0]# ls
aclocal.m4          config.sub    Doc      install-sh  m4               Misc          Objects  PCbuild        Python      Tools
CODE_OF_CONDUCT.md  configure     Grammar  Lib         Mac              Modules       Parser   Programs       README.rst
config.guess        configure.ac  Include  LICENSE     Makefile.pre.in  netlify.toml  PC       pyconfig.h.in  setup.py
[root@mysql-server Python-3.9.0]# ./configure --prefix=/usr/local/python3/
[root@mysql-server Python-3.9.0]# make && make install 
[root@mysql-server bin]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
[root@mysql-server bin]# ln -s /usr/local/python3/bin/python3  /usr/bin/python3
[root@mysql-server bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@mysql-server bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
[root@mysql-server bin]#
[root@mysql-server bin]# pip -V
pip 20.2.3 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)
[root@mysql-server bin]# pip3 -V
pip 20.2.3 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)
[root@mysql-server bin]# python3 -V
Python 3.9.0
[root@mysql-server bin]# python -V
Python 3.9.0
[root@mysql-server bin]#

装完Python 3.9.0,继续编译doxygen

[root@mysql-server build]# pwd
/root/doxygen/build
[root@mysql-server build]#
[root@mysql-server build]# cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "3.9")
Cmake Error at /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find FLEX (missing: FLEX_EXECUTABLE)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:577 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.19/Modules/FindFLEX.cmake:255 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:104 (find_package)


-- Configuring incomplete, errors occurred!
See also "/root/doxygen/build/CMakeFiles/CMakeOutput.log".

继续踩坑,提示缺少flex,这个插件centos8可以直接dnf安装。

[root@mysql-server build]# dnf -y install flex
[root@mysql-server build]# cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "3.9")
-- Found FLEX: /usr/bin/flex (found version "2.6.1")
-- Found BISON: /usr/bin/bison (found version "3.0.4")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for iconv_open
-- Looking for iconv_open - found
-- Performing Test ICONV_COMPILES
-- Performing Test ICONV_COMPILES - Success
-- Found Iconv: In glibc
-- One (and only one) of the ICONV_ACCEPTS_... tests must pass
-- Performing Test ICONV_ACCEPTS_NONCONST_INPUT
-- Performing Test ICONV_ACCEPTS_NONCONST_INPUT - Success
-- Performing Test ICONV_ACCEPTS_CONST_INPUT
-- Performing Test ICONV_ACCEPTS_CONST_INPUT - Failed
-- The javacc executable not found, using existing files
-- Configuring done
-- Generating done
-- Build files have been written to: /root/doxygen/build

[root@mysql-server build]# make && make install
[ 94%] Building CXX object src/CMakeFiles/doxymain.dir/sqlite3gen.cpp.o
[ 94%] Building CXX object src/CMakeFiles/doxymain.dir/stlsupport.cpp.o
[ 95%] Building CXX object src/CMakeFiles/doxymain.dir/symbolresolver.cpp.o
[ 95%] Building CXX object src/CMakeFiles/doxymain.dir/tagreader.cpp.o
[ 96%] Building CXX object src/CMakeFiles/doxymain.dir/template.cpp.o
[ 96%] Building CXX object src/CMakeFiles/doxymain.dir/textdocvisitor.cpp.o
[ 96%] Building CXX object src/CMakeFiles/doxymain.dir/tooltip.cpp.o
[ 97%] Building CXX object src/CMakeFiles/doxymain.dir/util.cpp.o
[ 97%] Building CXX object src/CMakeFiles/doxymain.dir/vhdldocgen.cpp.o
[ 98%] Building CXX object src/CMakeFiles/doxymain.dir/vhdljjparser.cpp.o
[ 98%] Building CXX object src/CMakeFiles/doxymain.dir/xmldocvisitor.cpp.o
[ 99%] Building CXX object src/CMakeFiles/doxymain.dir/xmlgen.cpp.o
[ 99%] Linking CXX static library ../lib/libdoxymain.a
[ 99%] Built target doxymain
Scanning dependencies of target doxygen
[ 99%] Building CXX object src/CMakeFiles/doxygen.dir/main.cpp.o
[100%] Linking CXX executable ../bin/doxygen
[100%] Built target doxygen
[  1%] Built target md5
[  1%] Built target lodepng
[ 12%] Built target mscgen
[ 12%] Checking the doxygen version for changes...
[ 12%] Built target check_doxygen_version
[ 12%] Checking the git repository for changes...
[ 12%] Built target check_git_repository
[ 14%] Built target doxygen_version
[ 26%] Built target qtools
[ 27%] Built target generate_configvalues_header
[ 31%] Built target vhdlparser
[ 38%] Built target doxycfg
[ 99%] Built target doxymain
[100%] Built target doxygen
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/bin/doxygen

装完doxgen,我们回到MySQL8.0.22源码文件夹,继续cmake,这次成功了如下:

-- MySQL 8.0.22
-- Looking for prlimit
-- Looking for prlimit - found
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Performing Test HAVE_CXX_W_error
-- Performing Test HAVE_CXX_W_error - Success
-- Performing Test HAVE_CXX_W_missing_noreturn
-- Performing Test HAVE_CXX_W_missing_noreturn - Success
-- Performing Test HAVE_CXX_W_conditional_uninitialized
-- Performing Test HAVE_CXX_W_conditional_uninitialized - Failed
-- Performing Test HAVE_CXX_W_suggest_attribute_format
-- Performing Test HAVE_CXX_W_suggest_attribute_format - Success
-- Performing Test HAVE_CXX_W_implicit_fallthrough
-- Performing Test HAVE_CXX_W_implicit_fallthrough - Success
-- Performing Test HAVE_CXX_W_format_truncation
-- Performing Test HAVE_CXX_W_format_truncation - Success
-- Performing Test HAVE_CXX_W_format_overflow
-- Performing Test HAVE_CXX_W_format_overflow - Success
-- Performing Test HAVE_CXX_W_parentheses_equality
-- Performing Test HAVE_CXX_W_parentheses_equality - Failed
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.9.0") found components: doxygen missing components: dot
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;RAPIDJSON_NO_SIZETYPEDEFINE;RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0;RAPIDJSON_SCHEMA_USE_STDREGEX=1;HAVE_CONFIG_H;__STDC_LIMIT_MACROS;__STDC_FORMAT_MACROS;_USE_MATH_DEFINES;LZ4_DISABLE_DEPRECATE_WARNINGS;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wjump-misses-init -Wstringop-truncation
-- CMAKE_CXX_FLAGS: -std=c++14 -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wstringop-truncation -Wlogical-op
-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -DDBUG_OFF -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -DDBUG_OFF -ffunction-sections -fdata-sections -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -DDBUG_OFF -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: /root/mysql-8.0.22/build

make -j32
make install

配置文件

MySQL的配置文件参数在官网有详解,也可以直接到安装路径bin目录直接./mysqld --help

参阅:https://dev.mysql.com/doc/refman/8.0/en/option-files.html

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
sql_mode=TRADITIONAL
explicit_defaults_for_timestamp=true
basedir=/usr/local/mysql
datadir=/data/mysql
connect_timeout=2

[mysqladmin]
force

[mysqldump]
quick

初始化数据库

[root@mysql-server bin]#  ./mysqld --initialize 
--user=mysql 
--datadir=/data/mysql 
--basedir=/usr/local/mysql 
--lower-case-table-names=1   #忽略大小写,这个参数在mysql8.0 之后是不能在my.cnf 中使用的,否则数据库无法启动。

2020-12-07T14:55:21.451737Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 7073
2020-12-07T14:55:21.453104Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2020-12-07T14:55:21.453114Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
2020-12-07T14:55:21.463783Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-12-07T14:55:21.846899Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-12-07T14:55:23.173404Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: m0aRel9qkN&Y

看都上面最后这里就成功了,接下来开机自启服务

[root@mysql-server bin]# cd ..
[root@mysql-server mysql]# cd support-files/
[root@mysql-server support-files]# ls
mysqld_multi.server  mysql-log-rotate  mysql.server
[root@mysql-server support-files]# cp mysql.server /etc/init.d/mysqld
[root@mysql-server support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/mysql-server.err'.
 SUCCESS!
[root@mysql-server ~]# systemctl restart mysqld
[root@mysql-server ~]# service mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!
[root@mysql-server ~]# chkconfig mysqld on
[root@mysql-server ~]#

到这里已经成功了,接下来验证端口,制作软连接。

[root@mysql-server support-files]# ss -lntp
State         Recv-Q         Send-Q                 Local Address:Port                  Peer Address:Port
LISTEN        0              128                          0.0.0.0:22                         0.0.0.0:*            users:(("sshd",pid=1049,fd=5))
LISTEN        0              128                             [::]:22                            [::]:*            users:(("sshd",pid=1049,fd=7))
LISTEN        0              70                                 *:33060                            *:*            users:(("mysqld",pid=7359,fd=33))
LISTEN        0              128                                *:3306                             *:*            users:(("mysqld",pid=7359,fd=35))
[root@mysql-server support-files]# cd ..
[root@mysql-server mysql]# ls
bin   include  LICENSE         LICENSE-test  mysqlrouter-log-rotate  README         README-test  share          var
docs  lib      LICENSE.router  man           mysql-test              README.router  run          support-files
[root@mysql-server mysql]# cd bin/
[root@mysql-server bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin/

初次使用需要修改MySQL的密码,方法有很多种,其中之一过程如下

[root@mysql-server doxygen]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.22

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Enter password: mysql> set password='123456';
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
[root@mysql-server doxygen]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.22 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>
原文地址:https://www.cnblogs.com/Release-R/p/14100668.html