在这里插入图片描述

Docker安装MySQL报错:mysqld failed while attempting to check config…mysqld: Can’t read dir of ‘/etc/mysql/conf.d/’…

[ERROR] [Entrypoint]: mysqld failed while attempting to check config command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.Frnt2oibYI mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)

1 最初的时候使用如下命令创建容器,但是创建之后通过docker ps查看不到启动的容器

[root@zxy_master mysql01]# docker run -p 33061:3306 --name mysql01 \
> -v /zxy/apps/docker_mysql/mysql01/conf:/etc/mysql \
> -v /zxy/apps/docker_mysql/mysql01/data:/var/lib/mysql \
> -v /zxy/apps/docker_mysql/mysql01/log:/var/log/mysql \
> -e MYSQL_ROOT_PASSWORD=123456 \
> -d mysql:5.7
358163e8d564ff111a41efe06e83798c9518a65300502c12a63776c6a3639a8c

2 通过查看该容器的日志,可以看到主要是因为读取不到/etc/mysql/conf.d/目录

[root@zxy_master apps]# docker logs -f 358163e8d564
2022-12-20 05:46:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
2022-12-20 05:46:26+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.XeHsvFblmW
        mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

3 -v /zxy/apps/docker_mysql/mysql01/conf:/etc/mysql

修改为

-v /zxy/apps/docker_mysql/mysql01/conf:/etc/mysql/conf.d \

[root@zxy_master apps]# docker run -p 33061:3306 --name mysql01 \
> -v /zxy/apps/docker_mysql/mysql01/conf:/etc/mysql/conf.d \
> -v /zxy/apps/docker_mysql/mysql01/data:/var/lib/mysql \
> -v /zxy/apps/docker_mysql/mysql01/log:/var/log/mysql \
> -e MYSQL_ROOT_PASSWORD=123456 \
> -d mysql:5.7
faf2312fd62ad4ebe05ba2cffa9917b47417cfad1f8175912e1e0bc6e089986c

4 再次检查已经启动成功,报错原因主要是没有指定到conf.d目录,导致容器在启动的时候找不到该目录。

[root@zxy_master apps]# docker ps
CONTAINER ID   IMAGE                                                  COMMAND                  CREATED         STATUS         PORTS                                                    NAMES
faf2312fd62a   mysql:5.7                                              "docker-entrypoint.s…"   3 seconds ago   Up 2 seconds   33060/tcp, 0.0.0.0:33061->3306/tcp, :::33061->3306/tcp   mysql01
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐