5.7.11编译安装详解

[root@localhost ~]# cat /etc/CentOS-release
CentOS Linux release 7.0.1406 (Core)

0x01 准备工作

1、到mysql官网下载mysql-community-5.7.11-1.el7.src.rpm源码包

rpm -ih mysql-community-5.7.11-1.el7.src.rpm会在用户目录下生成一个rpmbuild,从SOURCES文件夹内可以获得源码mysql-5.7.11.tar.gz,解压进入源码目录准备安装

2、因为mysql需要使用cmake编译,直接从yum从光盘的源中找到cmake

[root@localhost ~]# yum info cmake

名称 :cmake
架构 :x86_64
版本 :2.8.11
发布 :4.el7
大小 :6.7 M

3、准备开发环境yum groupinstall Additional Development,yum groupinstall Development tools之前的版本是Development tools和Development Libraries两个软件包组,我这里没有安装,因为只需要gcc和gcc-c++

0x02 mysql编译选项

部分常用编译选项

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql            [MySQL安装的根目录] -DMYSQL_DATADIR=/mydata/mysql/data               [MySQL数据库文件存放目录] -DSYSCONFDIR=/etc                        [MySQL配置文件所在目录] -DMYSQL_USER=mysql                       [MySQL用户名] -DWITH_MYISAM_STORAGE_ENGINE=1                 [MySQL的数据库引擎] -DWITH_INNOBASE_STORAGE_ENGINE=1                [MySQL的数据库引擎] -DWITH_ARCHIVE_STORAGE_ENGINE=1                [MySQL的数据库引擎] -DWITH_MEMORY_STORAGE_ENGINE=1                 [MySQL的数据库引擎] -DWITH_READLINE=1                        [MySQL的readline library,批量导入数据] -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock          [MySQL的通讯目录] -DWITH-LIBWRAP=0                         [是否支持libwrap]  -DENABLE_DOWNLOADS=1                       [编译时允许自主下载相关文件] -DDEFAULT_CHARSET=utf8                      [设置默认字符集为utf8] -DDEFAULT_COLLATION=utf8_general_ci               [设置默认排序字符集规则] 官方文档编译选项说明
0x03 安装过程(gcc / boost_1_59_0 / CURSES_LIBRARY ) [root@localhost ~]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mymnt/sqldata -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1  -DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock -DWITH-LIBWRAP=0 -DENABLE_DOWNLOADS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

-- Running cmake version 2.8.11
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error at cmake/os/Linux.cmake:41 (MESSAGE):
Unsupported compiler!
Call Stack (most recent call first):
CMakeLists.txt:162 (INCLUDE)

这是没有安装gcc和gcc-c++

[root@localhost mysql-5.7.11]# yum install gcc gcc-c++

再cmake一次

-- MySQL 5.7.11
-- Packaging as: mysql-5.7.11-Linux-x86_64
-- Looked for boost/version.hpp in and
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR
-- LOCAL_BOOST_ZIP
-- Could not find (the correct version of) boost.
-- MySQL currently requires boost_1_59_0

CMake Error at cmake/boost.cmake:81 (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:238 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:443 (INCLUDE)


-- Configuring incomplete, errors occurred!

这个就已经说明了You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>,Boost库是一个经过千锤百炼、可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一。

先从boost官网下载这个库boost_1_59_0.tar.gz

解压后把目录添加到-DWITH_BOOST编译选项中

继续编译报错如下

-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses library not found. Please install appropriate package,

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5d0588b399d53a905b43556f45da81e9.html