首先选择正确的云yum源
MYSQL的yum源在官网
dev.mysql.com/downloads/repo/yum/ 以上为官网yum地址进入网复制对应版本的DOWNLOAD复制地址即可
以下以centos7和centos8为例
下载源
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
安装源(这个源里面有8.0和5.7,两个版本等下会增加5.6和5.5)
rpm -ivh mysql80-community-release-el7-5.noarch.rpm
到源地址下进行修改源文件进行版本增加
cd /etc/yum.repos.d 进入源地址 ls 查看文件
查看输出
CentOS-Base.repo CentOS-Linux-Media.repo CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Plus.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-PowerTools.repo CentOS-Linux-Devel.repo CentOS-Linux-Sources.repo CentOS-Linux-Extras.repo mysql-community.repo CentOS-Linux-FastTrack.repo mysql-community-source.repo CentOS-Linux-HighAvailability.repo redhat.repo
以上看起来挺多只要修改其中一个文件即可
修改yum源
[root@192 yum.repos.d]# vi mysql-community.repo
# Enable to use MySQL 5.5 [mysql55-community] name=MySQL 5.5 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.7 [mysql57-community] name=MySQL 5.7 Community Server vim mysql-community.repo 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-2022 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [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-2022 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 下面还有很多
以上yum还是8.0在启用
enabled=1
改成enabled=0
需要安装的版本改成enabled=1
即可在yum中安装自己所需版本(适用于centos7和centos8)
建议老版本的安装5.7即可,向下兼容5.5和5.6
实在需要可以自行切换
选择好后查看一下是否启用成功
查看当前可安装的mysql版本
[root@www ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community mysql-tools-community MySQL Tools Community mysql57-community MySQL 5.7 Community Server
以上为选择5.7的输出结果
安装
sudo yum module disable mysql 禁用之前存在的sql模块 sudo yum install mysql-community-server 安装仓库中的
启动
service mysqld start 启动
相关文章
标签:mysql