docker logs -f mysql-temp
2025-11-14 01:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
2025-11-14 01:17:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-11-14 01:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2025-11-14T01:17:05.064977Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2025-11-14T01:17:05.323886Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.0) starting as process 1
2025-11-14T01:17:05.338396Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-11-14T01:17:05.737981Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-11-14T01:17:05.753945Z 1 [ERROR] [MY-013379] [Server] Server upgrade started with version 80400, but server upgrade of version 80044 is still pending.2025-11-14T01:17:05.754547Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2025-11-14T01:17:05.754608Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-11-14T01:17:06.284102Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.0) MySQL Community Server - GPL.
2025-11-14T01:17:06.284134Z 0 [System] [MY-015016] [Server] MySQL Server - end.
docker run -d --name mysql-temp \
-v /mnt/APP/mysql-server-data:/var/lib/mysql \
mysql:8.4 --upgrade=MINIMAL
13fb5f920e59c49dee18b5966a983572f18c4bcd0f3740c53489b5871b2dcb5a
root@truenas[/mnt/APP/mysql-server-data]# docker logs mysql-temp
2025-11-14 01:21:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.7-1.el9 started.
2025-11-14 01:21:46+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-11-14 01:21:46+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.7-1.el9 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2025-11-14T01:21:46.486026Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2025-11-14T01:21:46.767991Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.7) starting as process 1
2025-11-14T01:21:46.786566Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-11-14T01:21:47.098789Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-11-14T01:21:48.674335Z 0 [Warning] [MY-013378] [Server] Server upgrade is required, but skipped by command line option '--upgrade=MINIMAL'.
InnoDB: Progress in percents: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1002025-11-14T01:21:51.271019Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-11-14T01:21:51.271083Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2025-11-14T01:21:51.275790Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2025-11-14T01:21:51.331885Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.7' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2025-11-14T01:21:51.332177Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
然後,
SET GLOBAL innodb_fast_shutdown = 0; 設置 InnoDB 完全關閉模式,確保所有dirty page 都寫入磁盤,不會有數據丟失。
FLUSH TABLES WITH READ LOCK; 刷新所有表到磁盤,對所有表加讀鎖,防止寫入操作。
UNLOCK TABLES; 釋放表鎖。
docker exec mysql-temp mysql -uYOU-USER-NAME -pYOUR-PASSWORD -e "
SET GLOBAL innodb_fast_shutdown = 0;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;"
mysql: [Warning] Using a password on the command line interface can be insecure.
重啟試試:
ocker run -d --name mysql-temp \
-v /mnt/APP/mysql-server-data:/var/lib/mysql \
mysql:8.4
9388c2b2f4bcf09ae2a63c73e81d7f796faf4273b94ed00aa66ebeb98559c921
root@truenas[/mnt/APP/mysql-server-data]# docker logs -f mysql-temp
2025-11-14 01:23:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.7-1.el9 started.
2025-11-14 01:23:12+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-11-14 01:23:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.7-1.el9 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2025-11-14T01:23:12.698238Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2025-11-14T01:23:12.952908Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.7) starting as process 1
2025-11-14T01:23:12.967501Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-11-14T01:23:13.281082Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-11-14T01:23:14.582439Z 4 [System] [MY-013381] [Server] Server upgrade from '80044' to '80407' started.
2025-11-14T01:23:20.682007Z 4 [System] [MY-013381] [Server] Server upgrade from '80044' to '80407' completed.
2025-11-14T01:23:20.872102Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-11-14T01:23:20.872183Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2025-11-14T01:23:20.876381Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2025-11-14T01:23:20.906537Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2025-11-14T01:23:20.906596Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.7' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
root@truenas[/mnt/APP/mysql-server-data]# docker exec mysql-temp mysql -uYOU-USER-NAME -pYOUR-PASSWORD -e "SELECT VERSION();"
mysql: [Warning] Using a password on the command line interface can be insecure.
VERSION()
8.4.7
看起來升級完成了:
2025-11-14T01:23:14.582439Z 4 [System] [MY-013381] [Server] Server upgrade from ‘80044’ to ‘80407’ started. 2025-11-14T01:23:20.682007Z 4 [System] [MY-013381] [Server] Server upgrade from ‘80044’ to ‘80407’ completed.