Docker mysql [Warning] World-writable config file '.cnf' is is ignored

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/kinginblue/article/details/76863962

这其实是 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-cache
skip-name-resolve

character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

lower_case_table_names=1

max_allowed_packet=128M
innodb_log_file_size=256M

sql_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 ignored
mysql: [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 WindowsDocker 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 盘的用户目录下了,真是专治各种不服。

附、参考资料

展开阅读全文

Ignored XML validation warning: URI was not reported to parser for entity [document]

09-25

org.xml.sax.SAXParseException: URI was not reported to parser for entity [document]rn at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)rn at gnu.xml.aelfred2.SAXDriver.startExternalEntity(SAXDriver.java:631)rn at gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3358)rn at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:159)rn at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)rn at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)rn at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:222)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173)rn at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:126)rn at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:142)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126)rn at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)rn at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:269)rn at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)rn at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:83)rn at javax.servlet.GenericServlet.init(GenericServlet.java:211)rn at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)rn at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)rn at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)rn at org.apache.catalina.core.StandardService.start(StandardService.java:450)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:551)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)rn在resin 上不会出现这个错误在tomcat上就这样 论坛

warning C4091: 'extern ' : ignored on left of 'int' when no variable is declared

02-18

我的main函数如下rn[code=C/C++]rn#includern#includern#includernrn#include "structure.h"rn#include "format.h"rnrnvoid main()rnrn format();rn[/code]rnrn其中的structure.h文件如下rn[code=C/C++]rn#ifndef _STRUCTURE_Hrn#define _STRUCTURE_Hrnrnrn#define READ_ONLY 1 //只读rn#define WRITE_ONLY 2 //只写rn#define RW 3 //读写rnrn#define NOT_USED 0 //未被使用rn#define USED 1 //被使用rnrn#define ADMIN 1 //系统管理员rn#define DEFULT 0 //普通用户rnrn#define FILE 1 //文件rn#define DIRECTORY 2 //目录rnrn#define N_BLOCKS 15 //inode中磁盘块数组i_block的大小rn#define NAME_LEN 128 //文件名的最大长度rn#define FILE_NUM 256 //一个目录下可以拥有的文件(包括目录)的最大数目rn#define MAX_USER_NUM 16 //该文件系统最大的用户数目rnrn#define BLOCK_SIZE 1024 //盘块大小为 1KBrn#define BLOCKS_GROUP_NUM 100 //盘块组的数目rn#define BLOCKS_PER_GROUP 1000 //每组的盘块数rn#define INODES_PER_GROUP 100 //每组的inode数rn#define TOTAL_BLOCKS_NUM (BLOCKS_PER_GROUP*BLOCKS_GROUP_NUM) //总的盘块数rn#define TOTAL_INODES_NUM (INODES_PER_GROUP*BLOCKS_GROUP_NUM) //总的inode数rnrn#define FIRST_DATA_ADDR (sizeof(block_group)*BLOCKS_GROUP_NUM) //第一个数据块rnrnrn/*rn *超级块rn */rnstruct super_blockrn...;rnrnrn/*rn *组描述符rn */rnstruct group_descrn...;rnrnrn/*rn *inodern */rnstruct inodern...;rnrnrn/*rn *数据块组rn */rnstruct block_grouprn...;rnrnrn/*rn *文件,包括文件名(普通文件或者目录)和inode号rn */rnstruct file_entryrn...;rnrnrn/*rn *目录,用于存储指定具体目录所包含文件(包括目录)的数目和具体的文件内容(即dir_entry)rn */rnstruct dirrn...;rnrnrn/*rn *用户rn */rnstruct userrn...;rnrnrnextern FILE *fd;rnextern struct block_group block_group[BLOCKS_GROUP_NUM];rnextern struct user user[MAX_USER_NUM];rnextern dir dir;rnrn#endif[/code]rnrn编译的时候老是出错,如下:rn--------------------Configuration: simdisk - Win32 Debug--------------------rnCompiling...rnmain.cpprng:\operating system\课程设计\src\simdisk\structure.h(120) : warning C4091: 'extern ' : ignored on left of 'int' when no variable is declaredrng:\operating system\课程设计\src\simdisk\structure.h(120) : error C2143: syntax error : missing ';' before 'constant'rng:\operating system\课程设计\src\simdisk\structure.h(120) : fatal error C1004: unexpected end of file foundrnError executing cl.exe.rnCreating browse info file...rnBSCMAKE: error BK1506 : cannot open file '.\Debug\main.sbr': No such file or directoryrnError executing bscmake.exe.rnrnsimdisk.exe - 3 error(s), 1 warning(s)rnrnrn不知道哪里错了,请高手帮忙啊!!! 论坛

没有更多推荐了,返回首页