CentOS 7.7 源码安装MySQL5.7.27

那年仲夏 提交于 2019-12-16 03:04:16
  1. 下载mysql-5.7.27并上传到CentOS 7.7
    https://downloads.mysql.com/archives/community/
    在这里插入图片描述
    163镜像站下载http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.27.tar.gz
    在这里插入图片描述
  2. 创建安装目录文件夹及 mysql 用户,创建存放mysql数据库/data/mysql,创建log、socket与pid文件与相关存放目录。
[root@localhost MySQL_SRC]# ls
mysql-5.7.27.tar.gz
[root@localhost MySQL_SRC]# mkdir -p /usr/local/mysql
[root@localhost MySQL_SRC]# useradd mysql
useradd: user 'mysql' already exists
[root@localhost MySQL_SRC]# mkdir -p /data/mysql
[root@localhost MySQL_SRC]# mkdir /usr/local/mysql/{data,logs,tmp,run} -p
[root@localhost MySQL_SRC]# 
  1. 安装源码编译所需要的相关依赖包
    yum -y install cmake gcc-c++ ncurses-devel
[root@localhost MySQL_SRC]# yum -y install  cmake  gcc-c++  openssl-devel ncurses-devel zlib-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 1. base: mirrors.aliyun.com
 2. extras: mirrors.aliyun.com
 3. updates: mirrors.aliyun.com
Package cmake-2.8.12.2-2.el7.x86_64 already installed and latest version
Package gcc-c++-4.8.5-39.el7.x86_64 already installed and latest version
Package 1:openssl-devel-1.0.2k-19.el7.x86_64 already installed and latest version
Package ncurses-devel-5.9-14.20130511.el7_4.x86_64 already installed and latest version
Package zlib-devel-1.2.7-18.el7.x86_64 already installed and latest version
Nothing to do
[root@localhost MySQL_SRC]# 
  1. 下载上传mysql-boost-5.7.27.tar.gz,先解压mysql-5.7.27.tar.gz 后解压 mysql-boost-5.7.27.tar.gz。
    两个文件解压以后都会在同一个目录 mysql-5.7.27里面。 https://downloads.mysql.com/archives/community/
mysql-5.7.27/boost/boost_1_59_0/boost/pool/detail/mutex.hpp
mysql-5.7.27/boost/boost_1_59_0/boost/pool/detail/guard.hpp
mysql-5.7.27/boost/boost_1_59_0/boost/pool/poolfwd.hpp
mysql-5.7.27/boost/boost_1_59_0/boost/pool/simple_segregated_storage.hpp
mysql-5.7.27/boost/boost_1_59_0/boost/pool/pool.hpp
mysql-5.7.27/boost/boost_1_59_0/boost/pool/singleton_pool.hpp
[root@localhost MySQL_SRC]# ls
mysql-5.7.27  mysql-5.7.27.tar.gz  mysql-boost-5.7.27.tar.gz
[root@localhost MySQL_SRC]# cd mysql-5.7.27/
[root@localhost mysql-5.7.27]# ls
boost           cmd-line-utils   Docs                 libbinlogevents      man         plugin   source_downloads  support-files  win
BUILD           config.h.cmake   Doxyfile-perfschema  libbinlogstandalone  mysql-test  rapid    sql               testclients    zlib
client          configure.cmake  extra                libmysql             mysys       README   sql-common        unittest
cmake           COPYING          include              libmysqld            mysys_ssl   regex    storage           VERSION
CMakeLists.txt  dbug             INSTALL              libservices          packaging   scripts  strings           vio
[root@localhost mysql-5.7.27]# 
  1. 编译安装mysql(编译参数按实际情况制定)
[root@localhost mysql-5.7.27]# cmake . \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/opt/software/mysql-5.7.27/boost \
> -DSYSCONFDIR=/etc \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DENABLED_LOCAL_INFILE=1 \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/run/mysql.sock \
> -DENABLE_DTRACE=0 \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_EMBEDDED_SERVER=1
-- Running cmake version 2.8.12.2

在这里插入图片描述
make & make install

  1. 初始化mysql,5.7.6之后的版本初始化数据库不再使用mysql_install_db,而是使用: bin/mysqld
    –initialize
  2. 修改/etc/my.cnf文件,配置mysql
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!