MySQL系列—MySQL编译安装常见问题(或缺少依赖)及解决方法
MySQL 编译安装时需要安装的依赖(全):
yum install -y cmake
yum install ncurses ncurses-devel -y
yum install -y libarchive
yum install -y gcc gcc-c++
yum install -y openssl openssl-devel
yum install -y libtirpc libtirpc-devel
指定boost(下载、在编译项指定即可,见文章尾部: MySQL编译安装常用选项)
安装(安装方法见文章尾部)
以下问题经由(腾讯云服务器CentOS Linux release 8.0.1905 (Core)) 华为云服务器(CentOS Linux release 7.6.1810 (Core) ) 和 mysql-boost-5.7.30.tar.gz 测试而来
华为云服务器(CentOS Linux release 7.6.1810 (Core) )预装的软件比较多,出现提示需要安装的依赖比较少
**问题1**
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:71 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:100 (FIND_CURSES)
cmake/readline.cmake:193 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:581 (MYSQL_CHECK_EDITLINE)
出现原因:
缺少依赖
解决方法:
yum install ncurses ncurses-devel -y
=====================================
**问题2**
CMake Error at cmake/boost.cmake:88 (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.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:174 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:547 (INCLUDE)
出现原因:没有指定boost位置,或boost位置错误
解决方法:
cd 指令或ls等指令验证boost路径是否正确,修改即可。
若果没有boost就需要下载,然后指定就可以了
=====================================
**问题3**
-bash: cmake: command not found
出现原因:
没有安装cmake
解决方法:
yum install -y cmake
=====================================
**问题4**
cmake: symbol lookup error: cmake: undefined symbol: archive_write_add_filter_zstd
出现原因:
缺少依赖
解决方法:
yum install -y libarchive
=====================================
**问题5**
CMake Error at CMakeLists.txt:146 (PROJECT):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
出现原因:
缺少gcc-c++
解决方法:
yum install -y gcc gcc-c++
=====================================
**问题6**
Cannot find appropriate system libraries for WITH_SSL=system.
Make sure you have specified a supported SSL version.
Valid options are :
system (use the OS openssl library),
yes (synonym for system),
</path/to/custom/openssl/installation>
CMake Error at cmake/ssl.cmake:63 (MESSAGE):
Please install the appropriate openssl developer package.
Call Stack (most recent call first):
cmake/ssl.cmake:280 (FATAL_SSL_NOT_FOUND_ERROR)
CMakeLists.txt:579 (MYSQL_CHECK_SSL)
出现原因:
缺少依赖
解决方法:
yum install -y openssl openssl-devel
=====================================
**问题7**
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.4.2")
-- Checking for module 'libtirpc'
-- Package 'libtirpc', required by 'virtual:world', not found
CMake Error at cmake/rpc.cmake:76 (MESSAGE):
Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
Call Stack (most recent call first):
rapid/plugin/group_replication/configure.cmake:60 (MYSQL_CHECK_RPC)
rapid/plugin/group_replication/CMakeLists.txt:25 (INCLUDE)
出现原因:
缺少依赖
解决方法:
yum install -y libtirpc libtirpc-devel
=====================================
**问题8**
CMake Error at rapid/plugin/group_replication/rpcgen.cmake:100 (MESSAGE):
Could not find rpcgen
Call Stack (most recent call first):
rapid/plugin/group_replication/CMakeLists.txt:36 (INCLUDE)
出现原因:
缺少依赖
解决方法:
**安装rpcsvc-proto**
安装rpcsvc-proto方法如下:
下载rpcsvs-proto
https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4.2/rpcsvc-proto-1.4.2.tar.xz
解压
tar -xvf rpcsvc-proto-1.4.2.tar.xz
.configure
make && make install
注意:如果下载的是tar.gz包,这个包需要手动生成configure文件后才能编译安装rpcvsc-proto,需要安装很多依赖项,很繁琐,后面单独介绍
https://github.com/thkukuk/rpcsvc-proto/archive/refs/tags/v1.4.2.tar.gz
====================================
附:MySQL编译安装常用选项
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #指定MySQL安装目录
-DSYSCONFDIR=/usr/local/mysql/etc \ #指定MySQL配置文件my.cnf文件目录
-DMYSQL_USER=mysql \ #指定MySQL运行用户
-DDEFAULT_CHARSET=utf8 \ #指定默认字符集
-DDEFAULT_COLLATION=utf8_general_ci \ #指定默认排序字符集
-DMYSQL_DATADIR=/mysql/data \ #指定数据文件存放路径
-DWITH_BOOST=/usr/local/src/mysql-5.7.30/boost/boost_1_59_0 \ #指定boost 文件存放路径
-DENABLED_LOCAL_INFILE=1 \ #启用本地加载数据
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \ #指定mysql.sock文件路径
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 \
喜欢的朋友记得点赞、收藏、关注哦!!!