从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]:
(adsbygoogle = window.adsbygoogle || []).push({});