mysql-5.7.42升級到mysql-8.2.0(二進制方式)
注:本文在測試環(huán)境升級測試,建議先在測試環(huán)境驗證。在生產環(huán)境下還是先評估下,mysql-5.7.42為二進制方式安裝,所以用mysql-8.2.0二進制包升級
1、操作環(huán)境
1、查看當前數據庫版本
mysql> select@@version; +-----------+ | @@version | +-----------+ | 5.7.42 | +-----------+ 1 row in set (0.00 sec) mysql>
2、操作系統(tǒng)版本
[root@zyl-server ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [root@zyl-server ~]# [root@zyl-server ~]#
3、查看 Linux 系統(tǒng)上的 glibc(GNU C 庫)版本(這里很重要,要下載對應的內核mysql版本)
ldd --version 或者 rpm -q glibc **查看當前系統(tǒng)中的libstdc++版本:** strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX strings /usr/lib64/libstdc++.so.6 | grep CXXABI strings /usr/lib64/libstdc++.so.6 | grep GLIBC strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
否則后面升級完成后,啟動mysql會報錯:
報錯如下:
錯誤表明在啟動MySQL服務時出現了一些問題。主要的錯誤信息是關于缺少特定庫文件的版本,比如GLIBCXX_3.4.20、CXXABI_1.3.9、CXXABI_1.3.8、GLIBCXX_3.4.21以及GLIBC_2.25
。
這是由于安裝的MySQL版本與系統(tǒng)中可用的標準庫版本不兼容導致的(所以要對應下載相應的內核版本)。
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.3
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/mysql/bin/my_print_defaults)
Mar 20 21:10:55 db-mysql mysqld[7127]: /usr/local/mysql/bin/my_print_defaults: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by /usr/local/mysql/bin/../lib/private/libcrypto.so.3
2、升級準備
1、數據備份:在升級之前,務必對當前的 MySQL 5.7 數據庫進行完整備份,以防止數據丟失或損壞。確保備份文件的安全存儲,并測試其可恢復性。
2、安全性考慮:建議在測試環(huán)境中進行升級測試,以模擬真實場景并檢測潛在問題。這有助于減少生產環(huán)境中的不確定性和風險。
1、使用mysql-shell 檢查工具檢查兼容性
下載地址:https://downloads.mysql.com/archives/shell/
上傳mysql-shell:
安裝 mysql-shell rpm 軟件包::
rpm -Uvh mysql-shell-8.2.0-1.el7.x86_64.rpm --force --nodeps
查看 mysql-shel安裝版本:
mysqlsh --version
檢查該版本是否可以升級到MySQL 8.2.0:
mysqlsh -uroot -p -S /tmp/mysqld.sock -e "util.checkForServerUpgrade()"
注意:mysql.sock 地址在/etc/my.cnf 文件中查看。
檢查結果報告:
[root@db-mysql ~]# mysqlsh -uroot -p -S /tmp/mysqld.sock -e "util.checkForServerUpgrade()" Please provide the password for 'root@/tmp%2Fmysqld.sock': ****** Save password for 'root@/tmp%2Fmysqld.sock'? [Y]es/[N]o/Ne[v]er (default No): The MySQL server at /tmp%2Fmysqld.sock, version 5.7.42 - MySQL Community Server (GPL), will now be checked for compatibility issues for upgrade to MySQL 8.2.0... 1) Usage of old temporal type No issues found 2) MySQL 8.0 syntax check for routine-like objects No issues found 3) Usage of db objects with names conflicting with new reserved keywords No issues found 4) Usage of utf8mb3 charset Warning: The following objects use the utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved Unicode support. More information: https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html db_update - schema's default character set: utf8 db_update.users.name - column's default character set: utf8 db_update.users.email - column's default character set: utf8 5) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 6) Partitioned tables using engines with non native partitioning No issues found 7) Foreign key constraint names longer than 64 characters No issues found 8) Usage of obsolete MAXDB sql_mode flag No issues found 9) Usage of obsolete sql_mode flags Notice: The following DB objects have obsolete options persisted for sql_mode, which will be cleared during upgrade to 8.0. More information: https://dev.mysql.com/doc/refman/8.0/en/mysql-nutshell.html#mysql-nutshell-removals global system variable sql_mode - defined using obsolete NO_AUTO_CREATE_USER option 10) ENUM/SET column definitions containing elements longer than 255 characters No issues found 11) Usage of partitioned tables in shared tablespaces No issues found 12) Circular directory references in tablespace data file paths No issues found 13) Usage of removed functions No issues found 14) Usage of removed GROUP BY ASC/DESC syntax No issues found 15) Removed system variables for error logging to the system log configuration To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-13.html#mysqld-8-0-13-logging 16) Removed system variables To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://dev.mysql.com/doc/refman/8.0/en/added-deprecated-removed.html#optvars-removed 17) System variables with new default values To run this check requires full path to MySQL server configuration file to be specified at 'configPath' key of options dictionary More information: https://mysqlserverteam.com/new-defaults-in-mysql-8-0/ 18) Zero Date, Datetime, and Timestamp values No issues found 19) Schema inconsistencies resulting from file removal or corruption No issues found 20) Tables recognized by InnoDB that belong to a different engine No issues found 21) Issues reported by 'check table x for upgrade' command No issues found 22) New default authentication plugin considerations Warning: The new default authentication plugin 'caching_sha2_password' offers more secure password hashing than previously used 'mysql_native_password' (and consequent improved client connection authentication). However, it also has compatibility implications that may affect existing MySQL installations. If your MySQL installation must serve pre-8.0 clients and you encounter compatibility issues after upgrading, the simplest way to address those issues is to reconfigure the server to revert to the previous default authentication plugin (mysql_native_password). For example, use these lines in the server option file: [mysqld] default_authentication_plugin=mysql_native_password However, the setting should be viewed as temporary, not as a long term or permanent solution, because it causes new accounts created with the setting in effect to forego the improved authentication security. If you are using replication please take time to understand how the authentication plugin changes may impact you. More information: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatibility-issues https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-replication 23) Columns which cannot have default values No issues found 24) Check for invalid table names and schema names used in 5.7 No issues found 25) Check for orphaned routines in 5.7 No issues found 26) Check for deprecated usage of single dollar signs in object names No issues found 27) Check for indexes that are too large to work on higher versions of MySQL Server than 5.7 No issues found 28) Check for deprecated '.<table>' syntax used in routines. No issues found 29) Check for columns that have foreign keys pointing to tables from a diffrent database engine. No issues found Errors: 0 Warnings: 4 Notices: 1 NOTE: No fatal errors were found that would prevent an upgrade, but some potential issues were detected. Please ensure that the reported issues are not significant before upgrading.
檢查結果顯示:
沒有發(fā)現使用舊時態(tài)類型的問題
沒有發(fā)現與MySQL 8.0語法相關的問題
沒有發(fā)現與數據庫對象名稱與新保留關鍵字沖突的問題
發(fā)現某些對象使用了utf8mb3字符集,建議轉換為utf8mb4以獲得更好的Unicode支持
沒有發(fā)現與mysql模式中的表名沖突的問題
沒有發(fā)現使用具有非本地分區(qū)的引擎的分區(qū)表的問題
沒有發(fā)現外鍵約束名稱超過64個字符的問題
沒有發(fā)現使用已棄用的MAXDB sql_mode標志的問題
發(fā)現一些DB對象已經使用了過時的sql_mode選項
沒有發(fā)現ENUM/SET列定義中包含超過255個字符的元素的問題
沒有發(fā)現在共享表空間中使用分區(qū)表的問題
沒有發(fā)現表空間數據文件路徑中存在循環(huán)目錄引用的問題
沒有發(fā)現使用已刪除函數的問題
沒有發(fā)現已刪除的GROUP BY ASC/DESC語法的問題
無法運行需要指定完整MySQL服務器配置文件路徑的日志系統(tǒng)變量檢查
無法運行需要指定完整MySQL服務器配置文件路徑的已刪除系統(tǒng)變量檢查
無法運行需要指定完整MySQL服務器配置文件路徑的新默認值系統(tǒng)變量檢查
沒有發(fā)現零日期、日期時間和時間戳值的問題
沒有發(fā)現由文件刪除或損壞導致的模式不一致的問題
沒有發(fā)現被InnoDB識別為屬于不同引擎的表的問題
沒有發(fā)現通過'check table x for upgrade'命令報告的問題
發(fā)現新的默認身份驗證插件引入了兼容性問題,建議在升級后重新配置服務器以恢復到以前的默認身份驗證插件
沒有發(fā)現不能有默認值的列的問題
沒有發(fā)現在5.7中使用的無效表名和模式名的問題
沒有發(fā)現在5.7中遺留存儲過程的問題
沒有發(fā)現在對象名稱中使用單個美元符號的已棄用用法
沒有發(fā)現在高于MySQL Server 5.7版本上工作的索引過大的問題
沒有發(fā)現在例程中使用已棄用'.<table>'語法的問題
沒有發(fā)現具有外鍵指向不同數據庫引擎的表的列的問題總結:
錯誤:0
警告:4
注意事項:1
總結來說,檢查未發(fā)現會阻止升級的致命錯誤,但檢測到了一些潛在問題。在升級之前,請確保報告的問題并不重要。
3、mysqldump 導出數據文件和備份my.cnf
[root@db-mysql ~]# mysqldump -hlocalhost -uroot -p --all-databases > /home/db_back_2024.sql Enter password: [root@db-mysql ~]# cd /home/ [root@db-mysql home]# ll total 872 -rw-r--r-- 1 root root 889253 Mar 20 20:25 db_back_2024.sql drwx------ 2 oracle oinstall 127 Mar 18 05:12 oracle drwx------. 2 zyl zyl 62 Mar 16 22:24 zyl [root@db-mysql home]# cp /etc/my.cnf /home/5.7.37_my.cnf [root@zyl-mysql home]#
升級前先停止數據庫。
[root@db-mysql home]# systemctl stop mysqld
4、備份舊版mysql-5.7.42 安裝目錄下的文件和my.cnf文件(重要)
這里的安裝目錄在/usr/local/mysql
,根據自己實際備份。
cd /usr/local/ mkdir mysql-5.7.42_bk ##全部備份 mysql目錄下的文件 cp -R mysql/* mysql-5.7.42_bk ### 或者直接壓縮 ### tar -zcvf mysql-5.7.42_bk.tar.gz mysql [root@db-mysql bin]# tar zcf mysql-5.7.42_bk.tar.gz mysql
5、刪除舊版安裝目錄/usr/local/mysql下(bin、docs、includ、lib、share、support-files、LICENSE、README);
cd /usr/local/mysql rm -rf bin rm -rf docs rm -rf include rm -rf lib rm -rf README rm -rf LICENSE rm -rf share rm -rf support-files rm -rf man
6、備份mysqld 啟動文件
先備份/etc/init.d/ 下的mysqld 再 刪除/etc/init.d/ 下的mysqld
cd /etc/init.d/ tar zcf mysqld_5.7.42.tar.gz mysqld rm -rf /etc/init.d/mysqld
7、上傳、解壓安裝包(開始升級)
下載mysql8.2.0:
https://downloads.mysql.com/archives/community/
創(chuàng)建"mysql8.2.0-glibc"的文件夾,用于存放解壓文件。
mkdir /root/mysql8.2.0-glibc ##解壓 tar -xvf mysql-8.2.0-linux-glibc2.28-x86_64.tar -C /root/mysql8.2.0-glibc
##繼續(xù)解壓 cd /root/mysql8.2.0-glibc tar -xvf mysql-8.2.0-linux-glibc2.28-x86_64.tar.xz
將新解壓的mysql-8.2.0目錄復制到原來mysql安裝目錄下(/usr/local/mysql/),并修改文件權限。
[root@db-mysql mysql8.2.0-glibc]# mv mysql-8.2.0-linux-glibc2.17-x86_64/* /usr/local/mysql
##修改文件權限 chown -R mysql:mysql /usr/local/mysql
8、復制新版啟動文件到/etc/init.d/
將新解壓的mysql-8.2.0 的mysqld復制到/etc/init.d/ 下。
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
9、修改mysqld參數
vi /etc/init.d/mysqld
和舊版保持一致。
datadir=/usr/local/mysql/data basedir=/usr/local/mysql
10、啟動數據庫
[root@db-mysql ~]# systemctl daemon-reload [root@db-mysql ~]# [root@db-mysql ~]# systemctl start mysqld [root@db-mysql ~]# [root@db-mysql ~]# systemctl status mysqld
11、升級驗證
1、檢查登錄正常
mysql -u root -p [root@db-mysql mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.2.0 MySQL Community Server - GPL Copyright (c) 2000, 2023, Oracle and/or its affiliates. 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>
2、檢查升級版本
已由mysql-5.7.42 升級到 mysql-8.2.0 。
mysql> select@@version; +-----------+ | @@version | +-----------+ | 8.2.0 | +-----------+ 1 row in set (0.00 sec) mysql>
3、檢查數據
mysql> show databases; +--------------------+ | Database | +--------------------+ | db_update | | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.01 sec) mysql> use db_update; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +---------------------+ | Tables_in_db_update | +---------------------+ | users | +---------------------+ 1 row in set (0.00 sec) mysql> select * from users; +----+---------+------+---------------------+ | id | name | age | email | +----+---------+------+---------------------+ | 1 | Alice | 25 | alice@example.com | | 2 | Bob | 30 | bob@example.com | | 3 | Charlie | 22 | charlie@example.com | | 4 | David | 28 | david@example.com | | 5 | Eve | 35 | eve@example.com | +----+---------+------+---------------------+ 5 rows in set (0.00 sec) mysql>
到此這篇關于mysql-5.7.42升級到mysql-8.2.0 (二進制方式)的文章就介紹到這了,更多相關mysql-5.7.42升級到mysql-8.2.0 內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!