溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MySQL 5.7怎么升級(jí)到8.0

發(fā)布時(shí)間:2021-11-12 11:53:40 來(lái)源:億速云 閱讀:441 作者:iii 欄目:數(shù)據(jù)庫(kù)

這篇文章主要講解了“MySQL 5.7怎么升級(jí)到8.0”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“MySQL 5.7怎么升級(jí)到8.0”吧!

為什么升級(jí)到MySQL 8.0

  1.  基于安全考慮

  2.  基于性能和 穩(wěn)定性考慮:

  3.  mgr復(fù)制 ,并行復(fù)制writeset 等功能,性能提升

  4.  新的功能:

  5.  Hash join ,窗口函數(shù),DDL即時(shí),json 支持

  6.  原始環(huán)境中版本太多,統(tǒng)一版本

  7.  8.0版本基本已到穩(wěn)定期,可以大量投入生產(chǎn)環(huán)境中

升級(jí)之前需要了解

  1.     數(shù)據(jù)庫(kù)字典升級(jí)

  schema,mysql,information_schema,performance_schema,sys

  比如:密碼測(cè)試 mysql_native_password → caching_sha2_password

    2.  關(guān)鍵詞是不是兼容

  https://dev.mysql.com/doc/refman/8.0/en/keywords.html

  關(guān)鍵詞 added in查詢

    3.  SQL是不是兼容

  Group by處理上的不兼容,觸發(fā)器,存儲(chǔ)過(guò)程

  5.6 可以跑select id,count(*)from group by name;

  5.7,8.0是不是允許的 sql_mode控制

    4.  數(shù)據(jù)文件存儲(chǔ)格式是不是可以直接升級(jí)

  Perconal 和 mysql 存儲(chǔ)引擎一直,可以完全兼容

    5.  現(xiàn)有應(yīng)用的兼容性是否滿足

  自定義函數(shù),一些不規(guī)范的SQL語(yǔ)句等等

    6.  密碼策略

What Is New in MySQL 8.0

作為DBA需要基本了解8.0的一些功能

  •  Added in 添加功能

  •  Features Deprecated 棄用功能

  •  Features Removed 移除功能

MySQL 5.7怎么升級(jí)到8.0

MySQL 5.7怎么升級(jí)到8.0

MySQL 5.7怎么升級(jí)到8.0

升級(jí)準(zhǔn)備事項(xiàng)

已經(jīng)了解8.0的特性,應(yīng)對(duì)升級(jí)需要事先進(jìn)行驗(yàn)證和準(zhǔn)備工作

  1.  測(cè)試庫(kù)升級(jí),應(yīng)用驗(yàn)證

  2.  數(shù)據(jù)庫(kù)升級(jí),末知問(wèn)題發(fā)生

  3.  my.cnf配置信息調(diào)整

  4.  不兼容的操作方法,影響復(fù)制

  5.  一個(gè)平穩(wěn)的過(guò)濾,列如先升級(jí)一個(gè)從庫(kù),到所有從庫(kù)

  6.  最少停機(jī)時(shí)間,同樣生產(chǎn)數(shù)據(jù)恢復(fù)到環(huán)境,進(jìn)行模擬升級(jí),評(píng)估時(shí)間

  7.  怎樣進(jìn)行數(shù)據(jù)驗(yàn)證:行數(shù),表的數(shù)量 等等

  8.  考慮回滾方案

  9.  數(shù)據(jù)庫(kù)備份

升級(jí)前檢查

Mysql8.0還是提供了很多方便,不像之前一樣5.6升級(jí)5.7那樣?,F(xiàn)在可以通過(guò)mysql shell進(jìn)行確認(rèn)。

下面2種方式

#mysqlsh root:123456@192.168.244.130:3410 -e 'util.checkForServerUpgrade({"targetVersion":"8.0.19","configPath":"/etc/my3410.cnf"})';  MySQL  JS > util.checkForServerUpgrade('root@192.168.244.130:3410', {"password":"123456", "targetVersion":"8.0.11", "configPath":"/etc/my3410.cnf"})

MySQL 5.7怎么升級(jí)到8.0

MySQL 5.7怎么升級(jí)到8.0

MySQL 5.7怎么升級(jí)到8.0

按照提示的要求進(jìn)行更改

MySQL 5.7怎么升級(jí)到8.0

雖然shell做的很好,但還是存在一些缺陷。

比如以下內(nèi)容都不會(huì)存在提示:

1. basedir,

2. sql_mode ,

3. 半同步配置,

4. 密碼策略:default_authentication_plugin = mysql_native_password

開(kāi)始升級(jí)

官網(wǎng)下載對(duì)應(yīng)的tar包

https://downloads.mysql.com/archives/community/

下面是單機(jī)升級(jí),高可用架構(gòu)下 需要先升級(jí)從庫(kù),在逐步升級(jí)主庫(kù)。

執(zhí)行mysql_upgrade命令,會(huì)提示如下:

#/mysql8.0.19/bin/mysql_upgrade -uroot -p123456

MySQL 5.7怎么升級(jí)到8.0

在MySQL 8中mysql_upgrade客戶端現(xiàn)已棄用。升級(jí)客戶端執(zhí)行的操作現(xiàn)在由服務(wù)器完成。

要升級(jí),請(qǐng)使用較舊的數(shù)據(jù)目錄啟動(dòng)新的 MySQL 二進(jìn)制文件。自動(dòng)修復(fù)用戶表。升級(jí)后不需要重新啟動(dòng)。

所以必須在測(cè)試環(huán)境模擬準(zhǔn)備對(duì)應(yīng)SQL語(yǔ)句

正確操作如下:

1)登錄服務(wù)器進(jìn)行正常關(guān)閉:innodb_fast_shutdown是默認(rèn)是1,常常認(rèn)為是安全關(guān)閉

關(guān)閉innodb參數(shù)確認(rèn)

mysql> show variables like 'innodb_fast_shutdown';+----------------------+-------+| Variable_name        | Value |+----------------------+-------+| innodb_fast_shutdown | 1     |+----------------------+-------+1 row in set (0.00 sec)

確保數(shù)據(jù)都刷到硬盤(pán)上,更改成0

mysql> set global innodb_fast_shutdown=0;Query OK, 0 rows affected (0.01 sec)  mysql> shutdown;Query OK, 0 rows affected (0.00 sec)  *進(jìn)行備份。

2)用mysql8.0.19客戶端直接啟動(dòng)

啟動(dòng)mysql服務(wù)

[root@ss30 bin]# /opt/mysql8.0.19/bin/mysqld_safe --defaults-file=/etc/my3400.cnf --user=mysql &  [1] 15400  [root@ss30 bin]# 2020-04-25T13:07:16.591560Z mysqld_safe Logging to '/opt/data3400/logs/error.log'.  2020-04-25T13:07:16.636879Z mysqld_safe Starting mysqld daemon with databases from /opt/data3400/mysql  ##打開(kāi)另一個(gè)窗口查看error日志  [root@ss30 ~]# tail -f /opt/data3400/logs/mysql_error.log

登錄服務(wù)器確認(rèn)

[root@ss30 ~]# mysql -uroot -p -S /opt/data3400/mysql/mysql.sockEnter password:Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 10Server version: 8.0.19 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> select version();+-----------+| version() |+-----------+| 8.0.19    |+-----------+1 row in set (0.01 sec)

無(wú)myisam引擎

mysql> SELECT table_schema,table_name,engine FROM information_schema.tables where engine!='InnoDB';

剩下的就是驗(yàn)證 和 業(yè)務(wù)確認(rèn)否應(yīng)用正常。

感謝各位的閱讀,以上就是“MySQL 5.7怎么升級(jí)到8.0”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)MySQL 5.7怎么升級(jí)到8.0這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI