神奇的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

神奇了个鬼

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

相关推荐
极限实验室9 分钟前
使用 Docker Compose 简化 INFINI Console 与 Easysearch 环境搭建
数据库·docker·devops
飞翔的佩奇13 分钟前
Java项目:基于SSM框架实现的旅游协会管理系统【ssm+B/S架构+源码+数据库+毕业论文】
java·数据库·mysql·毕业设计·ssm·旅游·jsp
鬼才血脉1 小时前
Linux(centos)安装 MySQL 8
linux·mysql·centos
牧天白衣.2 小时前
Docker相关内容
docker·容器·eureka
一切顺势而行2 小时前
k8s 使用docker 安装教程
docker·容器·kubernetes
Andy杨2 小时前
20250707-2-第二章:Kubernetes 核心概念-K8s集群架构,生产部署K8s两_笔记
docker·容器
小安运维日记2 小时前
CKS认证 | Day4 最小化微服务漏洞
安全·docker·微服务·云原生·容器·kubernetes
bigFish啦啦啦4 小时前
docker proxy
docker
果子⌂5 小时前
容器技术入门之Docker环境部署
linux·运维·docker
Liudef067 小时前
Docker企业级应用:从入门到生产环境最佳实践
docker·容器·eureka