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.
2
Answers
For anyone, who struggles that issue as well. Here's how I made it work:
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.
That worked for me. Good luck!
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:
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:
Also Ensure that the WSL2 filesystem metadata is properly enabled. Add the following to your /etc/wsl.conf in your WSL2 instance:
Restart your WSL2 instance after making these changes