描述一下问题经过:
使用docker compose 部署mysql5.7
文件如下:
services:
mysql:
restart: always
image: mysql:5.7
container_name: mysql-dev
ports:
- 3306:3306
environment:
- MYSQL_DATABASE=dev
- MYSQL_ROOT_PASSWORD=123456
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 3s
retries: 5
volumes:
- mysqlVolume:/var/log/mysql
- mysqlVolume:/etc/mysql/conf.d
- mysqlVolume:/etc/mysql/mysql.conf.d
- mysqlVolume:/var/lib/mysql
volumes:
mysqlVolume:
出现:显示status为restarting
查看日志:docker logs 容器
发现如下错误:
TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-05-04T09:03:39.284335Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2024-05-04T09:03:39.284370Z 0 [ERROR] Aborting
问题解决:
docker volume ls
找到我们的命名卷我的卷 对应文件的则是 composeinfo_mysqlVolume(看样子使用文件名称拼接卷名称建立的)
docker inspect composeinfo_mysqlVolume
找到:
cd 进入该目录:
发现有一个错误文件:rm -rf error.log
docker restart 容器即可