2. 安装mysql
2.1 获取mysql安装yum源,并安装
[root@host ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[root@host ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
添加Mysql yum源
[root@host ~]# vi /etc/yum.repos.d/mysql-community.repo
在mysql-community.repo中添加如下内容
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 8.0
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
按下ESC,输入:wq
,保存并退出
查看mysql-community.repo
[root@host ~]# cat /etc/yum.repos.d/mysql-community.repo
看到如下图, 表示添加成功
查看mysql的子存储库,并安装(这里我修改为8.0的MySQL,所以查询到的是8.0的子存储库)
[root@host ~]# yum repolist enabled | grep mysql
!mysql80-community/x86_64 MySQL 8.0 Community Server 82
通过运行以下命令更新yum 源来更新MySQL
[root@host ~]# yum update
[root@host ~]# yum install mysql-community-server