{"id":200802,"date":"2025-05-06T14:22:50","date_gmt":"2025-05-06T06:22:50","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200802\/"},"modified":"2025-05-06T14:22:50","modified_gmt":"2025-05-06T06:22:50","slug":"docker-compose-%e9%83%a8%e7%bd%b2-mysql-%e5%a4%b1%e8%b4%a5%ef%bc%9a%e4%b8%ba%e4%bd%95%e5%87%ba%e7%8e%b0-mysqld-cant-read-dir-of-etc-mysql-conf-d-%e9%94%99%e8%af%af%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200802\/","title":{"rendered":"Docker Compose \u90e8\u7f72 MySQL \u5931\u8d25\uff1a\u4e3a\u4f55\u51fa\u73b0 \u201cmysqld: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Docker Compose \u90e8\u7f72 MySQL \u5931\u8d25\uff1a\u4e3a\u4f55\u51fa\u73b0 \u201cmysqld: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\uff1f<\/h1>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241115\/17316448376736cda5d7e65.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>docker compose \u65e0\u6cd5\u90e8\u7f72 mysql<\/strong><\/p>\n<p>\u5728 ubuntu \u7cfb\u7edf\u4e0a\u4f7f\u7528 docker-compose \u90e8\u7f72 mysql \u65f6\uff0c\u9047\u5230\u4e86\u65e0\u6cd5\u90e8\u7f72\u7684\u95ee\u9898\u3002\u4ee5\u4e0b\u4e3a\u76f8\u5173\u914d\u7f6e\uff1a<\/p>\n<pre>version: '3'\nservices:\n  mysql: \n    restart: always\n    image: mysql:8.2\n    network_mode: bridge\n    container_name: mysql\n    environment:\n      mysql_root_password: root123\n    command:\n      --character-set-server=utf8mb4\n      --collation-server=utf8mb4_general_ci\n      --explicit_defaults_for_timestamp=true\n      --lower_case_table_names=1\n      --max_allowed_packet=128m\n    volumes:\n      - \/etc\/localtime:\/etc\/localtime:ro\n      - \/data\/docker\/mysql\/mysql:\/var\/lib\/mysql\n      - \/data\/docker\/mysql\/etc:\/etc\/mysql:ro\n    ports:\n      - 3306:3306<\/pre>\n<p>\u91c7\u53d6\u4e86\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u6ce8\u91ca\u6389\u6302\u8f7d\uff0c\u76f4\u63a5\u542f\u52a8 mysql\uff0c\u6210\u529f\u542f\u52a8\u3002<\/li>\n<li>\u5c06\u5bb9\u5668\u4e2d\u7684 \/var\/lib\/mysql \u590d\u5236\u5230\u5bbf\u4e3b\u673a\u6307\u5b9a\u6302\u8f7d\u76ee\u5f55\u3002<\/li>\n<li>\u590d\u5236 \/etc\/mysql\uff0c\u7f16\u5199 my.cnf\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u5bbf\u4e3b\u673a \/data\/docker\/mysql\/etc\/mysql\/conf.d \u4e0b\u3002<\/li>\n<li>\u5220\u9664\u955c\u50cf\u3002<\/li>\n<li>\u6253\u5f00\u6302\u8f7d\u6ce8\u91ca\u3002<\/li>\n<\/ol>\n<p>\u6b64\u65f6\u51fa\u73b0\u9519\u8bef\uff1a<\/p>\n<pre>mysqld: can't read dir of '\/etc\/mysql\/conf.d\/' (os errno 2 - no such file or directory)<\/pre>\n<p><strong>\u9519\u8bef\u5206\u6790<\/strong><\/p>\n<p>\u6302\u8f7d\u7684\u76ee\u5f55 \/data\/docker\/mysql\/etc \u7f3a\u5c11 conf.d \u76ee\u5f55\u3002\u6302\u8f7d\u914d\u7f6e\u4e3a\uff1a<\/p>\n<pre>      - \/data\/docker\/mysql\/etc:\/etc\/mysql:ro<\/pre>\n<p>\u5bfc\u81f4\u542f\u52a8\u65f6\u627e\u4e0d\u5230 \/etc\/mysql\/conf.d \u76ee\u5f55\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6570\u636e\u5e93\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Docker Compose \u90e8&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200802","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200802"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200802\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}