一、在线安装(推荐)
1.配置仓库
[root@localhost ~]# vim /etc/yum.repos.d/mysql.repo
2.安装指定版本(提前配置好网络源)
[root@localhost ~]# yum install mysql-community-server-5.7.14 -y
3.检查
二、离线安装(推荐)
1.上传软件包
2.解压
[root@localhost ~]# tar xf mysql-5.7.14-1.el7.x86_64.rpm-bundle.tar
3.移除mariadb:
[root@localhost ~]# rpm -qa mariadb*
mariadb-libs-5.5.64-1.el7.x86_64
[root@localhost ~]# yum remove mariadb-libs
4.安装MySQL:
[root@localhost ~]# yum localinstall mysql-community-client-5.7.14-1.el7.x86_64.rpm mysql-community-server-5.7.14-1.el7.x86_64.rpm mysql-community-libs-5.7.14-1.el7.x86_64.rpm mysql-community-common-5.7.14-1.el7.x86_64.rpm
5.启动
[root@localhost ~]# systemctl enable --now mysqld.service
6.检查
(1)服务:
(2)端口:
(3)进程:
7.登录(5.6开始临时登录密码存放在日志/var/log/mysqld.log)
三、通用二进制安装(比较复杂,不推荐)
1.新建用户和组
[root@localhost ~]# groupadd -r -g 36 mysql
[root@localhost ~]# useradd -r -u 36 -g 36 -c 'MySQL Server' mysql
2.上传软件
3.初始化
(1)解压:
(2)改名或软连接:
(3)授权:
[root@localhost local]# chown -R mysql.mysql mysql/*
(4)初始化:
4.提供配置文件和脚本
[root@localhost local]# \cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@localhost local]# vim /etc/my.cnf
[root@localhost local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
5.启动服务
[root@localhost local]# chkconfig --add mysqld
[root@localhost local]# systemctl start mysqld
[root@localhost local]# chkconfig mysqld on
6.登录
[root@localhost local]# vim /etc/profile.d/mysql.sh //添加环境变量
加载到当前:
[root@localhost local]# source /etc/profile.d/mysql.sh
四、源码安装
1.上传
2.解压
[root@localhost ~]# tar xf mysql-boost-5.7.14.tar.gz -C /usr/local/src
3.配置与编译
[root@localhost ~]# yum install cmake gcc gcc-c++ ncurses-devel
[root@localhost mysql-5.7.14]# cd /usr/local/src/mysql-5.7.14/
[root@localhost mysql-5.7.14]#cmake . -DWITH_BOOST=/usr/local/src/mysql-5.7.14/boost/boost_1_59_0/
[root@localhostmysql-5.7.14]# make
4.安装
[root@localhost mysql-5.7.14]# make install
其余步骤和通用二进制相同:
如创建用户和组、初始化、提供配置文件和服务脚本、配置环境变量、启动服务。