Linux yum安装MySQL5.7


一、安装配置MySQL的yum源

1
2
3
4
5
6
7
8
9
10
# 安装MySQL的yum源,下面是RHEL6系列的下载地址
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# 安装yum-config-manager
yum install yum-utils -y
# 禁用MySQL5.6的源
yum-config-manager --disable mysql56-community
# 启用MySQL5.7的源
yum-config-manager --enable mysql57-community-dmr
# 用下面的命令查看是否配置正确
yum repolist enabled | grep mysql

wKioL1SY183ToG_4AAEh07Jk3jc235.jpg

    检查是否有mysql57-community-dmr这个源,如上图所示。

    二、yum安装MySQL5.7

1
2
# 安装MySQL5.7
yum install mysql-community-server

wKiom1SY15Kwk6pHAARS3FhtC9w643.jpg

 

如果安装失败 

给CentOS添加rpm源,并且选择较新的源

 

1)下载rpm包

[root@iZ2366ycl7sZ software]# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
--2019-03-29 14:45:46--  http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:46--  https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Connecting to dev.mysql.com|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:48--  https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
Resolving repo.mysql.com... 104.127.195.16
Connecting to repo.mysql.com|104.127.195.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5824 (5.7K) [application/x-redhat-package-manager]
Saving to: “mysql-community-release-el6-5.noarch.rpm”

100%[==============================================================================================>] 5,824       --.-K/s   in 0s      

2019-03-29 14:45:48 (506 MB/s) - “mysql-community-release-el6-5.noarch.rpm” saved [5824/5824]

补充:

如果上面的wget文件下载不了(有同学反馈无法下载),可直接下载 ;

git地址 http://t.istester.com:3000/istester/idoxu.git 

 

2)安装本地mysql源

[root@iZ2366ycl7sZ software]# yum localinstall mysql-community-release-el6-5.noarch.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking mysql-community-release-el6-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el6-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                              Arch                Version              Repository                                          Size
========================================================================================================================================
Installing:
 mysql-community-release              noarch              el6-5                /mysql-community-release-el6-5.noarch              4.3 k

Transaction Summary
========================================================================================================================================
Install       1 Package(s)

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-release-el6-5.noarch                                                                                 1/1 
  Verifying  : mysql-community-release-el6-5.noarch                                                                                 1/1 

Installed:
  mysql-community-release.noarch 0:el6-5                                                                                                

Complete!

3)验证是否安装成功

[root@iZ2366ycl7sZ software]# yum repolist all | grep mysql
mysql-connectors-community        MySQL Connectors Community     enabled:     83
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community             MySQL Tools Community          enabled:     74
mysql-tools-community-source      MySQL Tools Community - Source disabled
mysql55-community                 MySQL 5.5 Community Server     disabled
mysql55-community-source          MySQL 5.5 Community Server - S disabled
mysql56-community                 MySQL 5.6 Community Server     enabled:    493
mysql56-community-source          MySQL 5.6 Community Server - S disabled
mysql57-community-dmr             MySQL 5.7 Community Server Dev disabled
mysql57-community-dmr-source      MySQL 5.7 Community Server Dev disabled

修改默认版本为5.7

执行:

yum-config-manager --disable mysql56-community

yum-config-manager --enable mysql57-community-dmr

 

如上操作,是把5.6禁用,把5.7启用

此法,会有异常情况:

如果执行命令出现如下错误:

-bash: yum-config-manager: command not found

可用执行如下命令解决,然后继续上面的操作命令:

yum -y install yum-utils



    三、启动MySQL

1
2
3
4
5
# 禁用selinux
setenforce 0
sed -i '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config 
# 启动mysqld,启动之前先修改/etc/my.cnf配置文件,本文用默认的配置。
service mysqld start

wKiom1SY2NChgneUAAvRkNpLAXY980.jpg

    四、连接MySQL并修改密码

wKiom1SY6L2Tjmb6AAWhSSzlKQM824.jpg

转自:http://qicheng0211.blog.51cto.com/3958621/1593592/