《Docker系列》Docker安装MySQL报错:mysqld failed while attempting to check config....mysqld: Can‘t read dir

Posted DATA数据猿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《Docker系列》Docker安装MySQL报错:mysqld failed while attempting to check config....mysqld: Can‘t read dir相关的知识,希望对你有一定的参考价值。

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

以上是关于《Docker系列》Docker安装MySQL报错:mysqld failed while attempting to check config....mysqld: Can‘t read dir的主要内容,如果未能解决你的问题,请参考以下文章

《MySQL系列-主从相关》Docker安装MySQL,实现主从复制

mycat系列二Docker安装mycat并实现MySQL的读写分离

Docker安装mysql5.7

mycat系列一基于 Docker 搭建 MySQL 主从复制的详细教程

deepin中用docker安装mysql数据库

deepin中用docker安装mysql数据库