從centos6開始,官方版本的yum源中用mariadb替換了mysql,那麼安裝mysql通常須要去官網下載rpm包或者源碼包等方式。node
若是還想直接yum安裝的話須要本身配置mysql的yum源。mysql
官方yum源linux
https://dev.mysql.com/downloads/repo/yum/sql
下載對應版本mysql源到本地,若是系統是centos7,這裏選擇el7版本vim
安裝yum源 centos
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
查看mysql yum源,yum install mysql 默認安裝的是8.0版本post
[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=0this
vim /etc/yum.repos.d/mysql-community.repourl
# 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了centos7
[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]: