5 月 31 2020
MySQL 8.0.20 升級筆記
這陣子在處理 MySQL 5.6 -> 5.7 -> 8.0 升級的事,踩到一些地雷;紀錄一下。
目前新版的 MySQL 5.7 & 8.0 在全新安裝時會隨機產生 root 的密碼,並把密碼寫在 log 裡面。
這行為在自動化佈署時會遇上點麻煩,而避免隨機產生 root 密碼的方式是在 script 作這樣的事:
... mysqld --initialize-insecure systemctl start mysqld echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY '##########';" | mysql ...
(5.7 -> 8.0)升級方面,第一個變化是 mysql_upgrade 不需要執行了;server 在啟動時會檢查,並自行升版。
原本在 5.7 版仍能使用的幾個 Server System Variables 在 8.0 版必須移除:
- query_cache_type = 0
- query_cache_size = 0
- innodb_large_prefix = 1
- innodb_file_format = Barracuda
expire_logs_days 也應移除,改用 binlog_expire_logs_seconds。
我另外在 8.0 版補上這兩個設定:
- mysqlx = 0
- default_authentication_plugin = mysql_native_password
5.7 -> 8.0 的預設語系/字元集有變化:
character_set_server | collation_server | |
MySQL 5.7 | latin1 | latin1_swedish_ci |
MySQL 8.0 | utf8mb4 | utf8mb4_0900_ai_ci |
特別提 8.0.20 是因為使用 Percona XtraBackup 時踩到地雷(Ref. percona-xtrabackup-80 does not work with mysql 8.0.20);原因是 Redo log 格式被更改了,Changes in MySQL 8.0.20 (2020-04-27, General Availability) 裡面有這段:
InnoDB: Redo log records for modifications to undo tablespaces increased in size in MySQL 8.0 due to a change in undo tablespace ID values, which required additional bytes. The change in redo log record size caused a performance regression in workloads with heavy write I/O. To address this issue, the redo log format was modified to reduce redo log record size for modifications to undo tablespaces. (Bug #29536710)
(有興趣深究的可以看看這個 commit)
Percona XtraBackup – Documentation 裡面也有這段說明:
Due to changes in MySQL 8.0.20 released by Oracle at the end of April 2020, Percona XtraBackup 8.0, up to version 8.0.11, is not compatible with MySQL version 8.0.20 or higher, or Percona products that are based on it: Percona Server for MySQL and Percona XtraDB Cluster.
另外一顆地雷是 Drupal 7 在連線初始化時會設定 SQL mode,但 NO_AUTO_CREATE_USER 在 8.0 被拿掉了;目前先用 這個 comment 裡面夾帶的 patch 作修正。
12 月 14 2020
Percona XtraBackup for MySQL 8.0.22
這篇也算是作紀錄。
Percona 在 2020-10-23 貼出這文: MySQL New Releases and Percona XtraBackup Incompatibilities;裡面這段看起來感覺像是又被搞了…

特別強調 “又” 字是因為已經有過一次,而且放在 Percona XtraBackup – Documentation,但這次只張貼 blog post,沒寫在文件…
恰巧某台 11 月初新裝的 Linux 踩到坑,便持續關注 Percona XtraBackup 等新版釋出。

幾天前發現 Percona XtraBackup 的 github 有這個 pull request:PXB-2373 Release Notes for 8.0.22-15.0 (8.0),今天就在下載頁看到了(而且換了版本編號邏輯…
)

雖然 Percona XtraBackup 8.0 Release Notes 尚未更新,但剛測試的確沒看到 unknown error …
另外,MySQL 8.0.22 還有這變革…

By Joe Horn • Database 0 • Tags: MySQL, Percona XtraBackup