0

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

6
  • Does the .docker/mysql directory exist? What permissions does it have? Commented Dec 5, 2023 at 23:15
  • Can you try connecting from a separate container; docker-compose run db mysql -hdb? If you set ports: on the container, you can brew install or similar a MySQL client on the host and access it without doing anything Docker-specific. Commented Dec 5, 2023 at 23:52
  • Does this answer your question? MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container Commented Dec 5, 2023 at 23:58
  • @KKI no, this is not the case - mysql service inside container has not even started. In question I've posted complete logs from container, there are just above two lines Commented Dec 7, 2023 at 0:00
  • 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. Commented Dec 8, 2023 at 8:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.