CentOS7.4下MySQL5.7.28源码方式安装

Linux系统版本:CentOS7.4
MySQL版本:5.7.28
在Linux平台有RPM包、二进制包、源码包3中安装方式,这一篇文章主要是以源码包为例来介绍如何在Linux平台下进行MySQL的安装。
下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.28.tar.gz
国内镜像:http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-boost-5.7.28.tar.gz
具体安装步骤如下:
(1)首先卸载mariadb,不然后面会和安装mysql需要的库冲突:

[[email protected] ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[[email protected] ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

(2)创建mysql用户和用户组:

[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -r -g mysql -s /bin/false mysql

(3)创建MySQL安装目录和data目录:

[[email protected] ~]# mkdir /opt/mysql
[[email protected] ~]# mkdir -p /data/mysql
[[email protected] ~]# chown -R mysql:mysql /opt/mysql
[[email protected] ~]# chown -R mysql:mysql /data/mysql

(4)安装相关依赖:

[[email protected] ~]#yum install -y cmake make gcc gcc-c++ ncurses-devel  openssl-devel 

(4)编译安装:

[[email protected] ~]# tar -xvf mysql-boost-5.7.28.tar.gz
[[email protected] mysql-5.7.28]# cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 -DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/root/mysql-5.7.28/boost/boost_1_59_0/ \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_SSL=system
[[email protected] ~]#make && make install

猜你喜欢

转载自blog.51cto.com/13486869/2454631