Linux6 将 mysql5.1 升级到 mysql8.0(yum源)

Linux6 将 mysql5.1 升级到 mysql8.0(yum源)

 

 

 由于我的mysql是5.1版本的,导入SQL时,字符编码是utf8mb4的,mysql得版本5.5以上才支持,故低版本的报错。

utf8与utf8mb4(utf8 most bytes 4)

  • MySQL 5.5.3之后增加了utfmb4字符编码
  • 支持BMP(Basic Multilingual Plane,基本多文种平面)和补充字符
  • 最多使用四个字节存储字符

utf8mb4是utf8的超集并完全兼容utf8,能够用四个字节存储更多的字符。

标准的UTF-8字符集编码是可以使用1-4个字节去编码21位字符,这几乎包含了世界上所有能看见的语言。
MySQL里面实现的utf8最长使用3个字符,包含了大多数字符但并不是所有。例如emoji和一些不常用的汉字,如“墅”,这些需要四个字节才能编码的就不支持。

将mysql 5.1 升级到 8.0

官网下载对应系统的yum源

 

 

 将rpm包上传到服务器,然后安装

# yum install mysql80-community-release-el6-3.noarch.rpm 
Loaded plugins: fastestmirror
Setting up Install Process
...

Installed:
  mysql80-community-release.noarch 0:el6-3                                           

Complete!

8.0版本的yum源配置后,进行升级操作,升级前确认已经备份好数据库及对应的配置文件。关掉mysql服务。

[root@centos6 download]# service mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@centos6 download]# 

不需要卸载原来的mysql,使用“yum update”升级即可

[root@centos6 download]# yum update mysql-server
Loaded plugins: fastestmirror
Setting up Update Process
Loading mirror speeds from cached hostfile
...
=====================================================================================
 Package                        Arch      Version         Repository            Size
=====================================================================================
Installing:
 mysql-community-client         x86_64    8.0.19-1.el6    mysql80-community     47 M
     replacing  mysql.x86_64 5.1.73-8.el6_8
 mysql-community-devel          x86_64    8.0.19-1.el6    mysql80-community    7.8 M
     replacing  mysql-devel.x86_64 5.1.73-8.el6_8
 mysql-community-libs           x86_64    8.0.19-1.el6    mysql80-community    4.6 M
     replacing  mysql-libs.x86_64 5.1.73-8.el6_8
 mysql-community-libs-compat    x86_64    8.0.19-1.el6    mysql80-community    1.7 M
     replacing  mysql-libs.x86_64 5.1.73-8.el6_8
 mysql-community-server         x86_64    8.0.19-1.el6    mysql80-community    520 M
     replacing  mysql-server.x86_64 5.1.73-8.el6_8
Installing for dependencies:
 mysql-community-common         x86_64    8.0.19-1.el6    mysql80-community    727 k
 numactl                        x86_64    2.0.9-2.el6     base                  74 k

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

Total download size: 582 M
...

Replaced:
  mysql.x86_64 0:5.1.73-8.el6_8            mysql-devel.x86_64 0:5.1.73-8.el6_8       
  mysql-libs.x86_64 0:5.1.73-8.el6_8       mysql-server.x86_64 0:5.1.73-8.el6_8      

Complete!

升级后启动,会发现启动失败。

[root@centos6 download]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

查看日志

[root@centos6 ~]# tail /var/log/mysqld.log
2020-03-04T08:13:26.769860Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-03-04T08:13:26.770601Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19)  MySQL Community Server - GPL.
2020-03-04T08:17:11.990871Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 8227
2020-03-04T08:17:12.009990Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.
2020-03-04T08:17:12.075334Z 1 [ERROR] [MY-012263] [InnoDB] The Auto-extending innodb_system data file './ibdata1' is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2020-03-04T08:17:12.075438Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2020-03-04T08:17:12.573744Z 1 [ERROR] [MY-011013] [Server] Failed to initialize DD Storage Engine.
2020-03-04T08:17:12.573957Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2020-03-04T08:17:12.574061Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-03-04T08:17:12.574769Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19)  MySQL Community Server - GPL.

解决方法
# cd /var/lib/mysql
#rm -rf /var/lib/mysql/ib*
主要删除:ibdata1、ib_logfile0、ib_logfile1文件
之前有安装mysql-server5.1删除文件重构后,异常解决。

重启验证

[root@centos6 mysql]# /etc/init.d/mysqld restart
Stopping mysqld:                                           [  OK  ]
Initializing MySQL database:                               [  OK  ]
Starting mysqld:                                           [  OK  ]

查看mysql版本

[root@centos6 mysql]# mysql -V
mysql  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

说明已经升级成功,重新导入之前备份的数据库文件,即可使用。

 

posted @ 2020-03-04 16:31  Justtosee  阅读(1364)  评论(0编辑  收藏  举报