{"id":27466,"date":"2024-11-24T17:07:13","date_gmt":"2024-11-24T09:07:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27466\/"},"modified":"2024-11-24T17:07:13","modified_gmt":"2024-11-24T09:07:13","slug":"%e4%bd%bf%e7%94%a8-docker-compose-%e9%83%a8%e7%bd%b2-mysql-%e6%97%b6%ef%bc%8c%e9%81%87%e5%88%b0-mysqld-cant-read-dir-of-etc-mysql-conf-d-%e9%94%99%e8%af%af%e5%a6%82%e4%bd%95-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27466\/","title":{"rendered":"\u4f7f\u7528 Docker Compose \u90e8\u7f72 MySQL \u65f6\uff0c\u9047\u5230 \u201cmysqld: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173124812519150.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 Docker Compose \u90e8\u7f72 MySQL \u65f6\uff0c\u9047\u5230 \u201cmysqld: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 Docker Compose \u90e8\u7f72 MySQL \u65f6\uff0c\u9047\u5230 \u201cmysqld: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>  \u90e8\u7f72\u7591\u96be\u89e3\u7b54<\/strong><\/p>\n<p>\u672c\u6587\u65e8\u5728\u89e3\u51b3\u5728 ubuntu \u73af\u5883\u4e2d\u4f7f\u7528 docker-compose \u90e8\u7f72 mysql \u65f6\u9047\u5230\u7684\u9519\u8bef\u95ee\u9898\u3002<\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0\uff1a<\/strong><\/p>\n<p>\u7528\u6237\u5728\u6267\u884c\u4ee5\u4e0b docker-compose.yml \u6587\u4ef6\u65f6\u9047\u5230\u4e86\u9519\u8bef\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u9519\u8bef\u4fe1\u606f\u5982\u4e0b\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u9519\u8bef\u6e90\u4e8e \/etc\/mysql\/conf.d\/ \u76ee\u5f55\u4e0d\u5b58\u5728\u3002\u8be5\u76ee\u5f55\u7528\u4e8e\u5b58\u50a8 mysql \u914d\u7f6e\u6587\u4ef6\uff0c\u800c docker-compose \u914d\u7f6e\u5c06 \/data\/docker\/mysql\/etc \u6302\u8f7d\u5230\u4e86 \/etc\/mysql\/ \u4e0a\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u786e\u4fdd \/data\/docker\/mysql\/etc \u76ee\u5f55\u4e2d\u5b58\u5728 conf.d \u5b50\u76ee\u5f55\uff0c\u5e76\u5c06\u5176\u6302\u8f7d\u5230 \/etc\/mysql\/conf.d\/ \u4e0a\u3002\u4fee\u6539\u540e\u7684 docker-compose \u5982\u4e0b\uff1a<\/p>\n<pre>volumes:\n  - \/etc\/localtime:\/etc\/localtime:ro\n  - \/data\/docker\/mysql\/mysql:\/var\/lib\/mysql\n  - \/data\/docker\/mysql\/etc\/conf.d:\/etc\/mysql\/conf.d:ro<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 Docker Compose \u90e8\u7f72 MySQL \u65f6\uff0c\u9047\u5230 \u201cd: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u90e8\u7f72\u7591\u96be\u89e3\u7b54 \u672c\u6587\u65e8\u5728\u89e3\u51b3\u5728 ubuntu \u73af\u5883\u4e2d\u4f7f\u7528 docker-compose \u90e8\u7f72 mysql \u65f6\u9047\u5230\u7684\u9519\u8bef\u95ee\u9898\u3002 \u95ee\u9898\u63cf\u8ff0\uff1a \u7528\u6237\u5728\u6267\u884c\u4ee5\u4e0b docker-compose.yml \u6587\u4ef6\u65f6\u9047\u5230\u4e86\u9519\u8bef\uff1a version: &#8216;3&#8217; services: mysql: restart: always image: mysql:8.2 network_mode: bridge container_name: mysql environment: mysql_root_password: root123 command: &#8211;character-set-server=utf8mb4 &#8211;collation-server=utf8mb4_general_ci &#8211;explicit_defaults_for_timestamp=true &#8211;lower_case_table_names=1 &#8211;max_allowed_packet=128m volumes: &#8211; \/etc\/localtime:\/etc\/localtime:ro &#8211; \/data\/docker\/mysql\/mysql:\/var\/lib\/mysql &#8211; \/data\/docker\/mysql\/etc:\/etc\/mysql:ro ports: &#8211; 3306:3306 \u767b\u5f55\u540e\u590d\u5236 \u9519\u8bef\u4fe1\u606f\u5982\u4e0b\uff1a mysqld: can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217; (os errno 2 &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27466","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=27466"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27466\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}