一、安装
参考:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html
# 检测系统中是否安装了mysql yum list installed | grep mysql ### 显示内容 ### ### 我已经装过了……没装之前可能什么都没有,也可能有低版本的mysql mysql-community-client.x86_64 5.7.23-1.el6 @mysql57-community-dmr mysql-community-common.x86_64 5.7.23-1.el6 @mysql57-community-dmr mysql-community-libs.x86_64 5.7.23-1.el6 @mysql57-community-dmr mysql-community-release.noarch el6-5 @/mysql-community-release-el6-5.noarch mysql-community-server.x86_64 5.7.23-1.el6 @mysql57-community-dmr # 卸载低版本mysql,才能安装上mysql5.7 # remove后面是上面显示的文件(-y表示全过程选是),上面出现的全部都要remove掉 yum -y remove mysql-community-client.x86_64 mysql-community-common.x86_64 ... ### 显示内容 ### ... Removed: mysql-community-client.x86_64 0:5.7.23-1.el6 mysql-community-common.x86_64 0:5.7.23-1.el6 mysql-community-libs.x86_64 0:5.7.23-1.el6 mysql-community-release.noarch 0:el6-5 Dependency Removed: mysql-community-server.x86_64 0:5.7.23-1.el6 Complete! # 再检测一次,直到为空 # 下载mysql的yum源(el6-5表示惹的redhat6和sentos6-mysql5) wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm # 载入yum源 yum install mysql-community-release-el6-5.noarch.rpm # 查看mysql可用的安装源(安装源里面有mysql5的好几个版本) yum repolist enabled | grep mysql ### 显示内容 ### mysql-connectors-community MySQL Connectors Community 59 mysql-tools-community MySQL Tools Community 65 mysql56-community MySQL 5.6 Community Server 453 # 发现没有5.7版本的,修改repo文件,把5.7版本改为可用,5.6版本改为不可用 vi /etc/yum.repos.d/mysql-community.repo ### 显示内容 ### ############################################################################################################ [mysql-connectors-community] name=MySQL Connectors Community baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community] name=MySQL Tools Community baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # 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/6/$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/6/$basearch/ enabled=1 #把这个1改成0 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Note: MySQL 5.7 is currently in development. For use at your own risk. # Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/ [mysql57-community-dmr] name=MySQL 5.7 Community Server Development Milestone Release baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=0 #把这个0改成1 gpgcheck=1 gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ############################################################################################################ # 按i进入编辑模式! # 输入数字不要使用小键盘! # 按ESC键退出编辑模式! # 输入:wq 回车--保存并退出! # 再次检查