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

huangapple go评论159阅读模式
英文:

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

问题

I have a problem to run docker-compose.yml file for my Spring Boot Example.

当我运行docker-compose文件时,通过 docker-compose up -d,我遇到了下面显示的问题。

Here is the console log shown below in MySQL

以下是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.

How can I fix it?

我该如何修复它?

Here is the docker-compose.yml shown below

以下是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

英文:

I have a problem to run docker-compose.yml file for my Spring Boot Example.

When I run docker-compose file through docker-compose up -d, I got this issue shown below.

Here is the console log shown below in 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.

How can I fix it?

Here is the docker-compose.yml shown below

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

答案1

得分: -1

以下是已更新的 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

希望这对你有所帮助。

英文:

Here is the answer shown below

1 ) Revise MySQL image image: mysql/mysql-server:8.0.32 to image: mysql:latest

2 ) Define restart: on-failure to project-be

Here is the updated docker-compose.yml file shown below

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

huangapple
  • 本文由 发表于 2023年6月6日 01:35:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76408790.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定