神奇的bug之docker compose启动mysql失败

说明

本人开发环境是

windows 11 + wsl + ubuntu 22.04 + docker desktop + idea + docker compose

启动mysql 的配置如下

复制代码
  # Hive Metastore数据库服务
  hive-metastore-db:
    image: mysql:8.0
    container_name: hive-metastore-db
    hostname: hive-metastore-db
    networks:
      - hadoop-network
    ports:
      - "3306:3306"
    volumes:
      - hive-metastore-data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=hive
      - MYSQL_USER=hive
      - MYSQL_PASSWORD=hive
    command: [
      '--character-set-server=utf8mb4',
      '--collation-server=utf8mb4_unicode_ci',
      '--default-storage-engine=InnoDB',
      '--innodb-file-per-table=1'
    ]

其他的定义是正常的

包含

复制代码
volumes:
  hive_metastore_data:
  hive-metastore-data:

但是当我使用 hive-metastore-data 就会报错,hive_metastore_data 是正常的

演示如下

复制代码
2025-06-17 11:50:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.42-1.el9 started.
2025-06-17T11:50:08.307137374Z 2025-06-17 11:50:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-06-17T11:50:08.319708510Z 2025-06-17 11:50:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.42-1.el9 started.
2025-06-17T11:50:08.556133575Z '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2025-06-17T11:50:08.831452880Z 2025-06-17T11:50:08.826214Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2025-06-17T11:50:08.831491144Z 2025-06-17T11:50:08.828159Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.42) starting as process 1
2025-06-17T11:50:08.841343139Z 2025-06-17T11:50:08.840907Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-06-17T11:50:09.090728872Z 2025-06-17T11:50:09.090388Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-06-17T11:50:09.235934362Z mysqld: Table 'mysql.plugin' doesn't exist
2025-06-17T11:50:09.235984183Z 2025-06-17T11:50:09.235731Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
2025-06-17T11:50:09.236567653Z 2025-06-17T11:50:09.236277Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.237261156Z 2025-06-17T11:50:09.236810Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.237451989Z 2025-06-17T11:50:09.237245Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.238183075Z 2025-06-17T11:50:09.237877Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.238579404Z 2025-06-17T11:50:09.238312Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.239012346Z 2025-06-17T11:50:09.238718Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.239638256Z 2025-06-17T11:50:09.239165Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.312573283Z 2025-06-17T11:50:09.312145Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2025-06-17T11:50:09.387223566Z 2025-06-17T11:50:09.386914Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2025-06-17T11:50:09.394142183Z 2025-06-17T11:50:09.393867Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2025-06-17T11:50:09.394158304Z 2025-06-17T11:50:09.393939Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2025-06-17T11:50:09.398580272Z 2025-06-17T11:50:09.398376Z 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-06-17T11:50:09.402098092Z 2025-06-17T11:50:09.401817Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2025-06-17T11:50:09.402432073Z 2025-06-17T11:50:09.402063Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
2025-06-17T11:50:09.402459460Z 2025-06-17T11:50:09.402123Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
2025-06-17T11:50:09.402921244Z 2025-06-17T11:50:09.402707Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2025-06-17T11:50:09.402935035Z 2025-06-17T11:50:09.402793Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
2025-06-17T11:50:09.403040114Z 2025-06-17T11:50:09.402881Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-06-17T11:50:10.985084425Z 2025-06-17T11:50:10.984796Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.42)  MySQL Community Server - GPL.

从网上找了半天没有找到解决方案,后来想起来之前有也是使用这个镜像,所以就排除了镜像的问题。

后来对比一行一行删除测试发现是外部扩展卷的问题,

使用中横线的时候就是报这个异常

修改成下划线格式就正常了 hive_metastore_data

神奇了个鬼

有没有大佬出来解释一下原因

相关推荐
万象.1 分钟前
docker镜像操作实操
运维·docker·容器
时光追逐者32 分钟前
一款免费、简单、高效的在线数据库设计工具
数据库·mysql·oracle·sql server
满天星830357734 分钟前
【MySQL】表的操作
linux·服务器·数据库·mysql
Bdygsl1 小时前
MySQL(8)—— 事务
数据库·mysql
captain3761 小时前
MySQL增删改查
数据库·mysql
芒果披萨1 小时前
sql实操
数据库·sql·mysql
说实话起个名字真难啊2 小时前
docker入门之单进程哲学与多进程管理
docker
夕除2 小时前
Mysql--09
数据库·mysql
zhangren024682 小时前
Laravel8.x核心特性全解析
vue.js·spring boot·mysql
Java源码jdk2 小时前
基于javaweb和mysql的springboot校园二手书交易管理系统(java+springboot+vue+elementui+layui+mysql)
java·spring boot·mysql