繁体   English   中英

无法使用不同的 my.cnf 运行 mysql 容器

[英]Unable to run mysql container with different my.cnf

当我尝试使用运行时 --volume 选项更改 my.cnf 并使用图像 mysql/mysql-server:5.7.17 运行 mysql 容器时,我收到了错误消息。

[myhome tmp]# docker run -it -v /tmp/mysql/my.cnf:/etc/mysql/my.cnf  -e MYSQL_ROOT_PASSWORD=123456 mysql/mysql-server:5.7.17 
error: could not run mysql. This could be caused by a misconfigured my.cnf
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!

但是当我用 mysql:latest image 尝试同样的事情时,我能够运行这个图像:

[myhome tmp]# docker run -it -v /tmp/mysql/my.cnf:/etc/mysql/my.cnf  -e MYSQL_ROOT_PASSWORD=123456 mysql
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Initializing database files
2020-04-11T11:54:21.949032Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-04-11T11:54:21.949185Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 40
2020-04-11T11:54:27.882357Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-04-11 11:54:32+00:00 [Note] [Entrypoint]: Database files initialized
2020-04-11 11:54:32+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld will log errors to /var/lib/mysql/fc326f61d85d.err
mysqld is running as pid 92
2020-04-11 11:54:33+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.

2020-04-11 11:54:38+00:00 [Note] [Entrypoint]: Stopping temporary server
2020-04-11 11:54:41+00:00 [Note] [Entrypoint]: Temporary server stopped

2020-04-11 11:54:41+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2020-04-11T11:54:41.972267Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-04-11T11:54:41.972310Z 0 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2020-04-11T11:54:41.972376Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1
2020-04-11T11:54:42.834746Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-11T11:54:42.838151Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2020-04-11T11:54:42.872638Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2020-04-11T11:54:42.992548Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060


mbind: Operation not permitted

我的.cnf

[mysqld]
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
datadir=/var/lib/mysql
secure-file-priv=""
server-id=100
user=mysql
symbolic-links=0
!includedir /etc/mysql/conf.d/

请帮助我..为什么两个图像的行为都不一样。

该错误告诉您目录不存在。 您是否尝试过删除my.cnf的最后一行来检查它? 最好不要覆盖整个配置文件,而只覆盖您真正想要更改的那些设置。 https://hub.docker.com/_/mysql的官方文档指出:

请检查 mysql 映像本身中的相关文件和目录以获取更多详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM