MySQL docker container stuck reloading

My stack is win10/wsl2/ubuntu/docker desktop.

I’m stuck on running a MySQL docker container.
This is a part of my docker-compose.yml:

      mysql:
        hostname: a-mysql
        container_name: a-mysql
        image: mysql:8
        restart: unless-stopped
        volumes:
            - ./mysql_data:/var/lib/mysql
            - ./mysql/my.cnf:/etc/mysql/conf.d/my.cnf
            - ./mysql/dump:/docker-entrypoint-initdb.d
        env_file:
            - .env
        ports:
            - 7306:3306
        environment:
            TZ: "Asia/Jerusalem"
            MYSQL_ALLOW_EMPTY_PASSWORD: "no"
            MYSQL_ROOT_PASSWORD: ${MYSQL_INITDB_ROOT_PASSWORD}
            MYSQL_USER: ${MYSQL_INITDB_USER}
            MYSQL_PASSWORD: ${MYSQL_INITDB_USER_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_INITDB}
        networks:
            - external-php-net
            - internal-php-net
        command: ["mysqld", "--mysql-native-password=ON"]
        #command: --default-authentication-plugin=mysql_native_password

As well I have a Makefile:

up: #create and start containers
    @docker compose up -d

down: #stop containers
    @docker compose down

rebuild: #rebuild all
    @docker compose down && docker compose up -d --build

connect_back: #connect to laravel application
    @docker exec -it ]php-fpm bash

database-import:
    @../e.back/database/snapshots/database_import.sh

setup:  ## Create and start containers
    $(MAKE) up-redis
    $(MAKE) up-mysql
    $(MAKE) install
    $(MAKE) up-frontend
    $(MAKE) up-php
    #$(MAKE) init
    $(MAKE) up-nginx

So I come to the docker files containing folder using my ubuntu installation and run “make setup”.
What happens – all of the containers are running (there’re redis, php-fpm, admin, etc) – but MySQL is always rebooting.

The log I have for this situation:

2024-07-15 15:23:16 2024-07-15T12:23:16.324649Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-07-15 15:23:19 2024-07-15T12:23:19.486488Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-07-15 15:23:21 mysqld: Table 'mysql.plugin' doesn't exist
2024-07-15 15:23:21 2024-07-15T12:23:21.776189Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
2024-07-15 15:23:21 2024-07-15T12:23:21.776800Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.777242Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.951887Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.952560Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.952903Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.953261Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:21 2024-07-15T12:23:21.953587Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2024-07-15 15:23:23 2024-07-15T12:23:23.546298Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-07-15 15:23:23 2024-07-15T12:23:23.690225Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2024-07-15 15:23:23 2024-07-15T12:23:23.805946Z 0 [Warning] [MY-013595] [Server] Failed to initialize TLS for channel: mysql_main. See below for the description of exact issue.
2024-07-15 15:23:23 2024-07-15T12:23:23.806030Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2024-07-15 15:23:24 mysqld: Cannot change permissions of the file 'private_key.pem.temp' (OS errno 1 - Operation not permitted)
2024-07-15 15:23:24 2024-07-15T12:23:24.850250Z 0 [ERROR] [MY-010295] [Server] Could not set file permission for private_key.pem
2024-07-15 15:23:24 2024-07-15T12:23:24.850316Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-07-15 15:23:26 2024-07-15T12:23:26.457062Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.4.1)  MySQL Community Server - GPL.
2024-07-15 15:23:26 2024-07-15T12:23:26.457140Z 0 [System] [MY-015016] [Server] MySQL Server - end.
2024-07-15 15:23:29 2024-07-15 15:23:29+03:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.1-1.el9 started.
2024-07-15 15:23:33 2024-07-15 15:23:33+03:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-07-15 15:23:33 2024-07-15 15:23:33+03:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.1-1.el9 started.
2024-07-15 15:23:34 '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2024-07-15 15:23:34 mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
2024-07-15 15:23:35 2024-07-15T12:23:34.607950Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-07-15 15:23:35 2024-07-15T12:23:35.265552Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.1) starting as process 1
2024-07-15 15:23:35 2024-07-15T12:23:35.329779Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2024-07-15 15:23:35 2024-07-15T12:23:35.381988Z 0 [Warning] [MY-000054] [Server] World-writable config file '/var/lib/mysql/auto.cnf' is ignored.
2024-07-15 15:23:35 2024-07-15T12:23:35.398682Z 0 [Warning] [MY-010107] [Server] World-writable config file '/var/lib/mysql/auto.cnf' has been removed.
2024-07-15 15:23:35 2024-07-15T12:23:35.400891Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0e9d63d9-42a5-11ef-b1b9-0242ac130003.
2024-07-15 15:23:35 2024-07-15T12:23:35.533081Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

I’d appreciate any help with this, as I’ve been stuck for almost 2 days already. Thank you!

Well. I see the permission issue, and I think I tried all possibilities to fix it – changed permissions with chmod, added the meta thing to wsl.cnf and so on and so forth.

4

The issue seems related to permission errors and the initialization of MySQL.

Ensure that the files and directories mounted to the MySQL container have the correct permissions. Use chmod to set the appropriate permissions. For example:

chmod -R 755 ./mysql_data
chmod -R 644 ./mysql/my.cnf
chmod -R 755 ./mysql/dump

The error log mentions World-writable config file ‘/etc/mysql/conf.d/my.cnf’ is ignored. Ensure your config file does not have world-writable permissions:

chmod 644 ./mysql/my.cnf

Also Ensure that the WSL2 filesystem metadata is properly enabled. Add the following to your /etc/wsl.conf in your WSL2 instance:

[automount]
options = "metadata,umask=22,fmask=11"

Restart your WSL2 instance after making these changes

wsl --shutdown

1

For anyone, who struggles that issue as well.
Here’s how I made it work:

  1. Simply navigate to your project folder, where the Dockerfile and docker-compose.yml are located. Do that via your VSCode terminal, cmd or something NOT related to WSL + ubuntu and run ‘docker compose up‘.
    NO WSL NO UBUNTU, that’s important.

That would somehow initialize your container with the correct permissions on Windows. You’ll find that the container did run and all the permissions are set correctly.

  1. Go to your WSL and do the docker compose down
  2. From the WSL do the docker compose up.

That worked for me. Good luck!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật