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)

說明已經升級成功,重新導入之前備份的數據庫文件,即可使用。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM