使用MySQL yum源安装MySQL

#首先,将MySQL Yum存储库添加到系统的存储库列表中。
#在https://dev.mysql.com/downloads/repo/yum/地址中,下载mysql yum repository
[root@alone-mysql tools]# wget --no-check-certificate https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

 

#使用以下命令安装下载的发布包,其中U表示升级,v表示显示安装过程,h表示显示进度, 一旦发布包安装到您的系统上,yum update命令进行的任何系统范围的更新(或支持dnf的系统的dnf升级)
将自动升级您系统上的MySQL包,并且如果yum在MySQL yum存储库中找到替代包,那么它还将替换任何本机第三方包。
#也可以使用yum localinstall mysql80-community-release-el6-3.noarch.rpm命令来代替当前命令,这两个命令都是在/etc/yum.repos.d目录中释放两个文件 [root@alone-mysql tools]# rpm -Uvh mysql80-community-release-el6-3.noarch.rpm warning: mysql80-community-release-el6-3.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql80-community-relea########################################### [100%] #这样操作之后会在/etc/yum.repos.d目录中释放两个文件 [root@pinyoyougou-docker ~]# ls -l /etc/yum.repos.d | grep mysql -rw-r--r-- 1 root root 2076 4月 25 2019 mysql-community.repo -rw-r--r-- 1 root root 2108 4月 25 2019 mysql-community-source.repo #在MySQL Yum存储库、MySQL社区服务器的不同版本系列托管在不同的子存储库中。最新的GA系列(当前的MySQL 8.0)的子存储库在默认情况下是启用的,所有其他系列(例如,MySQL 5.7系列)的子存储库
在默认情况下是禁用的。使用此命令查看MySQL Yum存储库中的所有子存储库,并查看哪些子存储库已启用或禁用,当前命令其实就是查看/etc/yum.repos.d目录中的
mysql-community.repo和mysql-community-source.repo文件内容 [root@pinyoyougou-docker ~]# yum repolist all | grep mysql mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community 禁用 mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用 mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community 禁用 mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用 mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community 禁用 mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - So 禁用 mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 141 mysql-connectors-community-source MySQL Connectors Community - Sou 禁用 mysql-tools-community/x86_64 MySQL Tools Community 启用: 105 mysql-tools-community-source MySQL Tools Community - Source 禁用 mysql-tools-preview/x86_64 MySQL Tools Preview 禁用 mysql-tools-preview-source MySQL Tools Preview - Source 禁用 mysql55-community/x86_64 MySQL 5.5 Community Server 禁用 mysql55-community-source MySQL 5.5 Community Server - Sou 禁用 mysql56-community/x86_64 MySQL 5.6 Community Server 禁用 mysql56-community-source MySQL 5.6 Community Server - Sou 禁用 mysql57-community/x86_64 MySQL 5.7 Community Server 禁用 mysql57-community-source MySQL 5.7 Community Server - Sou 禁用 mysql80-community/x86_64 MySQL 8.0 Community Server 启用: 161 mysql80-community-source MySQL 8.0 Community Server - Sou 禁用

 

#这里我们需要禁用默认的mysql8,而启用mysql5.5
[root@alone-mysql tools]# yum-config-manager --disable mysql80-community
[root@alone-mysql tools]# yum-config-manager --enable mysql55-community
#再查看已经生效的mysql yum repository
[root@alone-mysql tools]# yum repolist enabled | grep mysql       
mysql-connectors-community           MySQL Connectors Community              94
mysql-tools-community                MySQL Tools Community                   78
mysql55-community                    MySQL 5.5 Community Server             487
#也可以手工对mysql-community.repo文件进行编辑,将mysql 5.5的enabled设置为1,将mysql8.0的enabled设置为0
[root@alone-mysql tools]# ls -l /etc/yum.repos.d/mysql-community.repo 
-rw-r--r--. 1 root root 2074 May 26 22:15 /etc/yum.repos.d/mysql-community.repo

#然后使用yum安装mysql
[root@alone-mysql tools]# yum install -y mysql-community-server
#启动mysql,在启动mysql的时候留意一下提示信息
[root@alone-mysql tools]# service mysqld start

#这里按照上面的提示设置一下mysql的密码
[root@alone-mysql tools]# /usr/bin/mysqladmin -u root password 'root'
#现在可以使用新密码登录我们的mysql
[root@alone-mysql tools]# mysql -uroot -p
Enter password:

 详细内容查看:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

 

posted @ 2019-05-27 18:45  ALonely  阅读(5628)  评论(0编辑  收藏  举报