Docker Compose Mysql - File './binlog.index' not found(OS errno 13 - Permission denied)

qvk1mo1f  于 2023-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(540)

我在运行Sping Boot Example的docker-compose.yml文件时遇到问题。
当我通过docker-compose up -d运行docker-compose文件时,我遇到了如下所示的问题。
下面是MySQL中显示的控制台日志

2023-06-05 20:31:34 [Entrypoint] MySQL Docker Image 8.0.32-1.2.11-server
2023-06-05 20:31:34 [Entrypoint] Starting MySQL 8.0.32-1.2.11-server
2023-06-05 20:31:34 2023-06-05T17:31:34.737915Z 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.
2023-06-05 20:31:34 2023-06-05T17:31:34.745368Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32) starting as process 1
2023-06-05 20:31:34 2023-06-05T17:31:34.750767Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-06-05 20:31:34 mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-06-05 20:31:34 2023-06-05T17:31:34.753319Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-06-05 20:31:34 2023-06-05T17:31:34.753479Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32)  MySQL Community Server - GPL.

我该怎么解决?
下面是docker-compose.yml

version: "3.9"
services:
  mysql:
    image: mysql/mysql-server:8.0.32
    container_name: mysql-database
    environment:
      MYSQL_DATABASE: username
      MYSQL_USER: username
      MYSQL_PASSWORD: pass
      MYSQL_ROOT_PASSWORD: pass
      MYSQL_ROOT_HOST: '%'
      MYSQL_PORT: 3306
    volumes:
      - ./db:/var/lib/mysql
    ports:
      - "3306:3306"

  project-be:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: project-be
    ports:
      - "9790:9790"
    depends_on:
      - mysql
    environment:
      - SPRING_PROFILES_ACTIVE=development
      - DB_USERNAME=username
      - DB_PASSWORD=pass
      - DB_URL=jdbc:mysql://host.docker.internal:3306/book
njthzxwz

njthzxwz1#

下面是答案
1)修改MySQL镜像image: mysql/mysql-server:8.0.32image: mysql:latest
2)定义restart: on-failureproject-be
下面是更新后的docker-compose.yml文件

version: "3.9"
services:
  mysql:
    image: mysql:latest
    container_name: mysql-database
    environment:
      MYSQL_DATABASE: username
      MYSQL_USER: username
      MYSQL_PASSWORD: pass
      MYSQL_ROOT_PASSWORD: pass
      MYSQL_ROOT_HOST: '%'
      MYSQL_PORT: 3306
    volumes:
      - ./db:/var/lib/mysql
    ports:
      - "3306:3306"

  project-be:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: project-be
    ports:
      - "9790:9790"
    depends_on:
      - mysql
    environment:
      - SPRING_PROFILES_ACTIVE=development
      - DB_USERNAME=username
      - DB_PASSWORD=pass
      - DB_URL=jdbc:mysql://host.docker.internal:3306/book
    restart: on-failure

相关问题