I have following service in my docker-compose.yaml:
db: image: "mysql:8.0.33" container_name: mywebsite-sql volumes: - .docker/mysql:/var/lib/mysql/ restart: unless-stopped environment: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} When I run docker compose, mysql container is up and running, but mysql service inside has not started, from container logs:
2023-11-26 23:22:45+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started. 2023-11-26 23:22:46+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' When I try to execute mysql command inside container:
sh-4.4# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) When I try to run mysqld by hand inside container, I'm getting following error:
sh-4.4# mysqld 2023-12-05T23:11:02.618578Z 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-12-05T23:11:02.626541Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33) starting as process 61 2023-12-05T23:11:02.631689Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive 2023-12-05T23:11:02.667038Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory. 2023-12-05T23:11:02.667419Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2023-12-05T23:11:02.667481Z 0 [ERROR] [MY-010119] [Server] Aborting 2023-12-05T23:11:02.669140Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33) MySQL Community Server - GPL. Data directory seems to be a problem - how can I fix it? I'm on MacOS Ventura 13.4 OS.
Edit: I can't even simply run container based on mysql images without any volumes, command "docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest" from official mysql docker docs gives same result as described in question. I'm trying run it on Apple M2
.docker/mysqldirectory exist? What permissions does it have?docker-compose run db mysql -hdb? If you setports:on the container, you canbrew installor similar a MySQL client on the host and access it without doing anything Docker-specific.