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

神奇了个鬼

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

相关推荐
程序员塔塔喵11 小时前
【MySQL篇|第一篇】索引失效的情况
数据库·mysql·索引失效
paopaokaka_luck11 小时前
宠物门店经营管理系统(销售与库存联动、进货自动记账、 退换与退款关联、员工个人业绩、ECharts 经营分析、滞销识别与客户分层、宠物档案年龄计算)
前端·javascript·spring boot·mysql·echarts·mybatis·1024程序员节
paopaokaka_luck13 小时前
心理咨询管理系统(WebSocket实时沟通、基于用户的协同过滤、 ECharts多维分析、 预约业务流程、预约校验与定时处理)
java·vue.js·spring boot·mysql·spring·echarts·1024程序员节
2301_322414280413 小时前
springboot农产品交易平台的设计与实现08055-计算机毕设 原创(免费领源码+部署教程+开发环境)
java·spring boot·redis·mysql·tomcat·maven·mybatis
ha_lydms15 小时前
AnalyticDB MySQL 技术架构
大数据·hadoop·mysql·adb·spark·dataworks·1024程序员节
Java开发追求者16 小时前
windows快速安装docker
windows·docker·安装·1024程序员节
Random Glow17 小时前
聚簇索引 vs 二级索引:回表、覆盖索引、索引下推
数据库·mysql·性能优化·innodb·1024程序员节·索引优化
骑着蜗牛撵大象32718 小时前
飞牛fnOS部署Damselfly:Compose编排、照片目录与7100固定访问
java·docker·rpc·dubbo·fnos·照片管理·damselfly
一掬净土18 小时前
kubelet 报错如下:docker does not support reopening container log files
docker·云原生·kubelet·logfiles
要开心吖ZSH18 小时前
一次线上锁风暴复盘:号源表大范围 DELETE 的隐患与分批删除改造
数据库·mysql·行锁·1024程序员节·间隙锁·lockwaittimeout