Docker compose file
version: '3'
services:
mysql:
container_name: docker_mysql_1
ports:
- 3306:3306/tcp
privileged: true
restart: on-failure
environment:
MYSQL_ROOT_PASSWORD: revenuewire
command:
- --innodb_file_per_table=0
- --innodb_checksum_algorithm=INNODB
- --binlog_checksum=NONE
- --sql_mode=NO_ENGINE_SUBSTITUTION
- --slow-query-log=1
- --slow-query-log-file=/var/log/mysql/my-slow.log
- --long_query_time=1
- --log-queries-not-using-indexes
image: mysql:8.0
volumes:
- mysql:/var/lib/mysql
network_mode: bridge
volumes:
mysql:
command to run
docker-compose up -d
Error
2024-07-31T12:03:25.087089Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.39) initializing of server in progress as process 80
2024-07-31T12:03:25.089461Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2024-07-31T12:03:25.089468Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2024-07-31T12:03:25.089537Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-07-31T12:03:25.089947Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.39) MySQL Community Server - GPL.
Try to access mysql volume using Docker Desktop Dashboard
Solved
Look like it is mac VM problem. After do the following, it works. Just do not know why
- use docker desktop dashboard to delete all mysql images.
- delete volume docker_mysql
- stop and delete all containers
- shut down mac
- start mac
- docker-compose up -d