为了方便记录一下MySQL的安装过程,特意写此文进行记录;
1、安装环境
[root@VM_0_9_centos ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
2、MySQL下载
有两种方式:
2.1官网下载
1、登录官网
https://dev.mysql.com/downloads/mysql/
2、选择版本
3、如果要选择往期版本,可以到【archive】中进行选择,本文选择mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz版本进行安装。
4、获取下载地址
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
2.2 国内镜像下载
从官网下载会比较缓慢,我的显示需要N(N>5)个小时,如果从官网下载比较快的小伙伴可以不用看国内这个步骤。
1、选择镜像源
`mysql国内镜像下载网址:`
http://mirrors.sohu.com/mysql/
http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/
`开源镜像站点汇总:`
http://segmentfault.com/a/1190000000375848
2、选择MySQL的镜像,选择的版本为mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz.
http://mirrors.sohu.com/mysql/MySQL-5.7/
3、获取下载地址:
http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
2.3 下载到本地
`进入到/usr/src/目录下`
[root@VM_0_9_centos ~]# cd /usr/src/
`下载MySQL`
[root@VM_0_9_centos src]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
3、安装准备工作
3.1检查是否存在mysql/mariadb
centos7系统自带mariadb数据库,先卸载再安装mysql,防止有冲突.
`查看是否存在mysql`
[root@VM_0_9_centos src]# rpm -qa | grep -i mysql
`查看是否存在mariadb`
[root@VM_0_9_centos src]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
3.2 卸载已已存在的mysql/mariadb
`卸载mariadb`
[root@VM_0_9_centos src]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
`再次查看,已经卸载`
[root@VM_0_9_centos src]# rpm -qa | grep mariadb
4、安装配置
4.1、目录准备
`进入下载目录进行解压`
[root@VM_0_9_centos plugin]# cd /usr/src
[root@VM_0_9_centos src]# tar -zvxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
`移动到/usr/local中,并重命名为mysql`
[root@VM_0_9_centos src]# mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql