mysql 添加yum源及选择安装的版本

从centos6开始,官方版本的yum源中用mariadb替换了mysql,那么安装mysql一般需要去官网下载rpm包或者源码包等方式。

如果还想直接yum安装的话需要自己配置mysql的yum源。

 

官方yum源

https://dev.mysql.com/downloads/repo/yum/

 

下载对应版本mysql源到本地,如果系统是centos7,这里选择el7版本

 

安装yum源      

rpm -ivh mysql80-community-release-el7-1.noarch.rpm

 

查看mysql yum源,yum install mysql  默认安装的是8.0版本

[root@linux-node yum.repos.d]# yum repolist|grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community                  74
mysql-tools-community/x86_64      MySQL Tools Community                       74
mysql55-community/x86_64          MySQL 5.5 Community Server                 427
mysql56-community/x86_64          MySQL 5.6 Community Server                 429
mysql80-community/x86_64          MySQL 8.0 Community Server                  49

 

复制代码

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                                      Arch                                    Version                                            Repository                                          Size
==================================================================================================================================================================================================================
Installing:
 mysql-community-client                                       x86_64                                  8.0.13-1.el7                                       mysql80-community                                   26 M
 mysql-community-libs                                         x86_64                                  8.0.13-1.el7                                       mysql80-community                                  2.3 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-libs-compat                                  x86_64                                  8.0.13-1.el7                                       mysql80-community                                  2.1 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
Installing for dependencies:
 mysql-community-common                                       x86_64                                  8.0.13-1.el7                                       mysql80-community                                  554 k
Updating for dependencies:
 postfix                                                      x86_64                                  2:2.10.1-7.el7                                     base                                               2.4 M

Transaction Summary
==================================================================================================================================================================================================================
Install  3 Packages (+1 Dependent package)
Upgrade             ( 1 Dependent package)

Total download size: 33 M
Is this ok [y/d/N]:

复制代码

 

要修改默认安装版本的话,可以直接修改mysql的yum源文件,yum配置文件里从5.5版本到8.0都有,只不过默认只开启了mysql8.0。更改别的版本记得将mysql8.0的源 enable=0

vim /etc/yum.repos.d/mysql-community.repo

复制代码

# 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=1    #打开mysql5.6源
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

复制代码

 

再yum  install看一下,默认已经是mysql5.6了

复制代码

[root@linux-node2 yum.repos.d]# yum install mysql 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.42-2.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.42-2.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-libs.x86_64 0:5.6.42-2.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) >= 5.6.10 for package: mysql-community-libs-5.6.42-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-common.x86_64 0:5.6.42-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                                   Arch                                      Version                                           Repository                                            Size
==================================================================================================================================================================================================================
Installing:
 mysql-community-client                                    x86_64                                    5.6.42-2.el7                                      mysql56-community                                     20 M
 mysql-community-libs                                      x86_64                                    5.6.42-2.el7                                      mysql56-community                                    2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
Installing for dependencies:
 mysql-community-common                                    x86_64                                    5.6.42-2.el7                                      mysql56-community                                    257 k

Transaction Summary
==================================================================================================================================================================================================================
Install  2 Packages (+1 Dependent package)

Total download size: 22 M
Is this ok [y/d/N]:

复制代码

转载于:https://my.oschina.net/u/3371661/blog/3056332

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值