一看必会系统:使用rpm升级mysql 5.5到5.6,yum升级5.6到5.7

来源:本站原创 mysql_mariadb 超过2,846 views围观 0条评论

使用rpm及yum升级mysql 5.5到5.6,5.6到5.7

使用yum 安装指定版本mysql

升级版

1.停用应用

2.备份所有库

3.增加源

  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

 

https://repo.mysql.com/

5.5.35 https://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-server-5.5.35-2.el7.x86_64.rpm

5.6.34 https://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-server-5.6.35-2.el7.x86_64.rpm

yum -y install gcc gcc-c++ make cmake automake autoconf libxml2 libxml2-devel zlib zlib-devel ncurses ncurses-devel
yum -y install libaio libaio-devel net-tools wget

———yum的升级方式  5.6升5.7

下载和安装官方源

[root@localhost ~]# rpm -ivh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
Retrieving https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
warning: /var/tmp/rpm-tmp.yAt0Yg: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql57-community-release-el7-11 ################################# [100%]

确认源是否安装完成

yum repolist all| grep mysql

mysql-cluster-7.5-community/x86_64                         MySQL Cluster 7.5 Community                                                     disabled
mysql-cluster-7.5-community-source                         MySQL Cluster 7.5 Community – Source                                            disabled
mysql-cluster-7.6-community/x86_64                         MySQL Cluster 7.6 Community                                                     disabled
mysql-cluster-7.6-community-source                         MySQL Cluster 7.6 Community – Source                                            disabled
mysql-connectors-community/x86_64                          MySQL Connectors Community                                                      enabled:     45
mysql-connectors-community-source                          MySQL Connectors Community – Source                                             disabled
mysql-tools-community/x86_64                               MySQL Tools Community                                                           enabled:     59
mysql-tools-community-source                               MySQL Tools Community – Source                                                  disabled
mysql-tools-preview/x86_64                                 MySQL Tools Preview                                                             disabled
mysql-tools-preview-source                                 MySQL Tools Preview – Source                                                    disabled
mysql55-community/x86_64                                   MySQL 5.5 Community Server                                                      disabled
mysql55-community-source                                   MySQL 5.5 Community Server – Source                                             disabled
mysql56-community/x86_64                                   MySQL 5.6 Community Server                                                      disabled
mysql56-community-source                                   MySQL 5.6 Community Server – Source                                             disabled
mysql57-community/x86_64                                   MySQL 5.7 Community Server                                                      enabled:    247
mysql57-community-source                                   MySQL 5.7 Community Server – Source                                             disabled
mysql80-community/x86_64                                   MySQL 8.0 Community Server                                                      disabled
mysql80-community-source                                   MySQL 8.0 Community Server – Source                                             disabled
updates/7/x86_64                                           CentOS-7 – Updates – mirrors.aliyun.com                                         enabled:  2,41
  
  
[root@localhost ~]# rpm -qa |grep mysql   ——-现有版本
mysql-community-libs-5.6.34-2.el7.x86_64
mysql-community-server-5.6.34-2.el7.x86_64
mysql-community-common-5.6.34-2.el7.x86_64
mysql-community-client-5.6.34-2.el7.x86_64
mysql57-community-release-el7-11.noarch

[root@localhost ~]# yum update mysql-community-server-5.7.11-1.el7.x86_64 -y

升级到指定版本要指定详细版本号.请注意

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Updating   : mysql-community-common-5.7.11-1.el7.x86_64                                                                                             1/8
  Updating   : mysql-community-libs-5.7.11-1.el7.x86_64                                                                                               2/8
  Updating   : mysql-community-client-5.7.11-1.el7.x86_64                                                                                             3/8
  Updating   : mysql-community-server-5.7.11-1.el7.x86_64                                                                                             4/8
  Cleanup    : mysql-community-server-5.6.34-2.el7.x86_64                                                                                             5/8
  Cleanup    : mysql-community-client-5.6.34-2.el7.x86_64                                                                                             6/8
  Cleanup    : mysql-community-libs-5.6.34-2.el7.x86_64                                                                                               7/8
  Cleanup    : mysql-community-common-5.6.34-2.el7.x86_64                                                                                             8/8
  Verifying  : mysql-community-common-5.7.11-1.el7.x86_64                                                                                             1/8
  Verifying  : mysql-community-libs-5.7.11-1.el7.x86_64                                                                                               2/8
  Verifying  : mysql-community-client-5.7.11-1.el7.x86_64                                                                                             3/8
  Verifying  : mysql-community-server-5.7.11-1.el7.x86_64                                                                                             4/8
  Verifying  : mysql-community-server-5.6.34-2.el7.x86_64                                                                                             5/8
  Verifying  : mysql-community-client-5.6.34-2.el7.x86_64                                                                                             6/8
  Verifying  : mysql-community-libs-5.6.34-2.el7.x86_64                                                                                               7/8
  Verifying  : mysql-community-common-5.6.34-2.el7.x86_64                                                                                             8/8

Updated:
  mysql-community-server.x86_64 0:5.7.11-1.el7                                                                                                           

Dependency Updated:
  mysql-community-client.x86_64 0:5.7.11-1.el7       mysql-community-common.x86_64 0:5.7.11-1.el7       mysql-community-libs.x86_64 0:5.7.11-1.el7     

Complete!

[root@localhost ~]# !net
netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1767/sshd          
tcp6       0      0 :::3306                 :::*                    LISTEN      82400/mysqld       
tcp6       0      0 :::22                   :::*                    LISTEN      1767/sshd          

mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

 

———RPMR的升级方式 5.5到5.6

wget https://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-common-5.5.35-2.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-libs-5.5.35-2.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-client-5.5.35-2.el7.x86_64.rpm

wget https://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-common-5.6.34-2.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-libs-5.6.34-2.el7.x86_64.rpm
wget https://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-client-5.6.34-2.el7.x86_64.rpm
按顺序安装
mysql-community-common
mysql-community-libs
mysql-community-client
mysql-community-server

 

4.在线升级

5.备用方案。卸载后再安装,再导入数据

6.回退方案

——–正确的安装过程

[root@localhost ~]# rpm -ivh mysql-community-client-5.5.35-2.el7.x86_64.rpm
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-client-5.5.35-2.e################################# [100%]
error: unpacking of archive failed on file /usr/bin/mysqlcheck;5a97f082: cpio: read
error: mysql-community-client-5.5.35-2.el7.x86_64: install failed
[root@localhost ~]# rpm -ivh mysql-community-client-5.5.35-2.el7.x86_64.rpm
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-client-5.5.35-2.e################################# [100%]
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# rpm -ivh mysql-community-server-5.5.35-2.el7.x86_64.rpm
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-server-5.5.35-2.e################################# [100%]
[root@localhost ~]# systemctl status mysql
Unit mysql.service could not be found.
[root@localhost ~]# systemctl status mysqld
● mysqld.service – MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@localhost ~]# systemctl restart mysqld

———–登陆测试

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>
mysql>

——————–5.5.45到5.6.34 升级过程

报错
[root@localhost ~]# rpm -ivh mysql-community-common-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-common-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
    file /usr/share/mysql/errmsg-utf8.txt from install of mysql-community-common-5.6.34-2.el7.x86_64 conflicts with file from package mysql-community-common-5.5.35-2.el7.x86_64

解决  先卸载   mysql-community-common-5.5.35-2.el7.x86_64
    [root@localhost ~]# rpm -qa |grep mysql
mysql-community-common-5.5.35-2.el7.x86_64
mysql-community-client-5.5.35-2.el7.x86_64
mysql-community-libs-5.5.35-2.el7.x86_64
mysql-community-server-5.5.35-2.el7.x86_64
[root@localhost ~]# yum remove mysql-community-common-5.5.35-2.el7.x86_64

Removed:
  mysql-community-common.x86_64 0:5.5.35-2.el7                                                                                                           

Dependency Removed:
  mysql-community-client.x86_64 0:5.5.35-2.el7       mysql-community-libs.x86_64 0:5.5.35-2.el7       mysql-community-server.x86_64 0:5.5.35-2.el7     

Complete!

开始安装
[root@localhost ~]# rpm -ivh mysql-community-common-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-common-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-common-5.6.34-2.e################################# [100%]
[root@localhost ~]# rpm -ivh mysql-community-client-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-client-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
    mysql-community-libs(x86-64) >= 5.6.10 is needed by mysql-community-client-5.6.34-2.el7.x86_64
[root@localhost ~]# rpm -ivh mysql-community-libs-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-libs-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-libs-5.6.34-2.el7################################# [100%]
[root@localhost ~]# rpm -ivh mysql-community-client-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-client-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-client-5.6.34-2.e################################# [100%]
[root@localhost ~]# rpm -ivh mysql-community-server-5.6.34-2.el7.x86_64.rpm
warning: mysql-community-server-5.6.34-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-server-5.6.34-2.e################################# [100%]
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
启动

systemctl restart  mysqld.service
[root@localhost ~]# !mysql
mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.34 MySQL Community Server (GPL)  —————————验证版本正确,数据都在

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| bass               |
| budget             |
| mysql              |
| performance_schema |
| test               |
+——————–+
6 rows in set (0.05 sec)

mysql>

 

 

——-安装失败
[root@localhost ~]# rpm -ivh mysql-community-server-5.5.35-2.el7.x86_64.rpm
error: Failed dependencies:
    mysql-community-client(x86-64) = 5.5.35-2.el7 is needed by mysql-community-server-5.5.35-2.el7.x86_64
[root@localhost ~]# rpm -ivh mysql-community-client-5.5.35-2.el7.x86_64.rpm
Preparing…                          ################################# [100%]
Updating / installing…
   1:mysql-community-client-5.5.35-2.e################################# [100%]
error: unpacking of archive failed on file /usr/bin/mysqlcheck;5a97f082: cpio: read
error: mysql-community-client-5.5.35-2.el7.x86_64: install failed    ——-安装包损坏,重新下载
[root@localhost ~]#

———–报错
[root@localhost ~]# rpm -ivh mysql-community-server-5.5.35-2.el7.x86_64.rpm 
error: Failed dependencies:
    mysql-community-client(x86-64) = 5.5.35-2.el7 is needed by mysql-community-server-5.5.35-2.el7.x86_64
    mysql-community-common(x86-64) = 5.5.35-2.el7 is needed by mysql-community-server-5.5.35-2.el7.x86_64
    net-tools is needed by mysql-community-server-5.5.35-2.el7.x86_64
    perl(DBI) is needed by mysql-community-server-5.5.35-2.el7.x86_64
————解决
按顺序安装
mysql-community-common
mysql-community-libs
mysql-community-client
mysql-community-server

    net-tools is needed by mysql-community-server-5.5.35-2.el7.x86_64
    perl(DBI) is needed by mysql-community-server-5.5.35-2.el7.x86_64
    [root@localhost ~]# yum install -y net-tools  perl-DBI
———-解决
    mysql-community-client(x86-64) = 5.5.35-2.el7 is needed by mysql-community-server-5.5.35-2.el7.x86_64
    mysql-community-common(x86-64) = 5.5.35-2.el7 is needed by mysql-community-server-5.5.35-2.el7.x86_64

——–如有冲突

删除原有mariadb
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost ~]# yum remove -ymariadb-libs-5.5.52-1.el7.x86_64

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3737转载请注明转自CCIE那点事
如果喜欢:点此订阅本站