Docker mysql [Warning] World-writable config file '.cnf' is is ignored
来源:互联网 发布:outlook smtp 端口号 编辑:程序博客网 时间:2024/05/17 05:10
这其实是 Docker 在 Windows 下的坑! 理论上 Docker for Mac
也会遇到同样的问题。
零、问题描述
近期都在 Docker Compose
部署项目,在服务器上好好的,但到了我本地的 Windows 开发机上,Mysql 的字符集设置一直不生效,醉了。
./docker-compose.yml
内容:
version: "2"services: mysql: build: ./builds/mysql ports: - "3386:3306" volumes: - "./data/mysql/data:/var/lib/mysql" - "./data/mysql/conf:/etc/mysql/conf.d" restart: always environment: MYSQL_DATABASE: blua MYSQL_USER: blua MYSQL_PASSWORD: blua MYSQL_ROOT_PASSWORD: blua # orrder service so no...
我的./data/mysql/conf/mysql.cnf
内容:
[client]default-character-set=utf8mb4[mysql]default-character-set=utf8mb4
我的./data/mysql/conf/docker.cnf
内容:
[mysqld]skip-host-cacheskip-name-resolvecharacter-set-client-handshake=FALSEcharacter-set-server=utf8mb4collation-server=utf8mb4_unicode_ciinit_connect='SET NAMES utf8mb4'lower_case_table_names=1max_allowed_packet=128Minnodb_log_file_size=256Msql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
然后查看 mysql
这个 service 的日志:
# docker-compose logs mysql
发现了两句警告:
mysql: [Warning] World-writable config file '/etc/mysql/conf.d/docker.cnf' is ignoredmysql: [Warning] World-writable config file '/etc/mysql/conf.d/docker.cnf' is ignored
然后再进去查看这两个配置文件的权限信息:
# docker-compose exec mysql bash# ls -l /etc/mysql/conf.d/-rwxrwxrwx 1 root root 309 Jun 20 16:47 docker.cnf-rwxrwxrwx 1 root root 78 Jun 20 16:47 mysql.cnf
Mysql 的配置文件因为读写权限不安全(竟然是完全的读-写-执行权限)被 Mysql 的安全机制忽了,进而导致我的字符集设置没生效。
Linux 下不会出现这种问题,我的 Windows8.1 用的是 DockerToolBox
,不太确定 Docker for Windows
和 Docker for Mac
会不会出现这种问题。
Google 一下,发现也有很多类似的问题:docker-compose volumes 777
但是我不太想深究了。。反正都是 Windows 的锅。。应该还是有解决方案的,或者深究的话还可以了解下 volumns 的挂载和权限机制。。
一、解决方案
第一种讨论:在 DockerFile 里做这一步的文件复制,并且修改文件权限:Fixing World-writable MySql error in Docker
第二种讨论:修改 docker-machine VM 默认的挂载的权限?MySQL in Docker on Windows: World-writable files ignored
第三种:最简单的方案,把你的项目,放到你的用户目录下!Docker Engine 会自动挂载用户目录 C:\Users (Windows) or /Users (Mac)。项目放在用户目录(或子目录)下就会被挂载进 Docker Engine,此时就不会再出现共享进去的文件的权限被变成 root 用户的 -rwxrwxrwx 文件了!Docker Compose Get started 里的 Shared folders, volumes, and bind mounts
也有提及这一点。
第三种应该就是最好的方案了,以前项目都放 D 盘,现在要用 Docker 跑的都放 C 盘的用户目录下了,真是专治各种不服。
附、参考资料
- Docker mysql: [Warning] World-writable config file ‘/etc/mysql/conf.d/.cnf’ is ignored
- docker-compose volumes 777
- Docker Compose Get started Tip > Shared folders, volumes, and bind mounts
- Docker mysql [Warning] World-writable config file '.cnf' is is ignored
- Warning: World-writable config file '/etc/my.cnf' is ignored
- Warning: World-writable config file '/etc/my.cnf' is ignored
- Warning: World-writable config file '/etc/my.cnf' is ignored
- Warning: World-writable config file '/etc/mysql/my.cnf' is ignored
- Warning: World-writable config file '/data0/mysql/3306/my.cnf' is ignored
- linux MYSQL Warning: World-writable config file './my.cnf' is ignored解决方法
- MySQL无法重启问题解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- MySQL无法重启问题解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- MySQL无法重启问题解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- Warning: World-writable config file '/etc/mysql/my.cnf' is ignored
- MySQL无法重启报错Warning: World-writable config file ‘/etc/my.cnf’ is ignored的解决方法
- MySQL无法重启报错Warning: World-writable config file ‘/etc/my.cnf’ is ignored的解决方法
- warning: World-writable config file /opt/lampp/etc/my.cnf is ignored
- 解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- 解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored
- 装xampp遇到World-writable config file‘/opt/lampp/etc/my.cnf’is ignored错误
- mysql启动warning: World-writable config file
- HTML 元素
- HDU 6068 Classic Quotation
- android studio jdk jre 路径 百度地图 高德地图 sha1获取
- 使用样式表自定义Qt小部件(摘自Qt帮助文档)
- Android源码学习——linker(4)
- Docker mysql [Warning] World-writable config file '.cnf' is is ignored
- Python等十多种编程语言使用代理示例
- BZOJ 1036 树的统计Count(树链剖分(点权)入门题)
- 高级排序算法(一)
- 【Leetcode】【python】Longest Substring Without Repeating Characters
- windows环境下使用pip安装python的sklean包
- 立志于学
- (9)js函数形参与实参的个数可以不同
- Python相关的人工智能库