{"id":7813,"date":"2024-11-14T10:57:33","date_gmt":"2024-11-14T02:57:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7813\/"},"modified":"2024-11-14T10:57:33","modified_gmt":"2024-11-14T02:57:33","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:\/\/fwq.ai\/blog\/7813\/","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><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173124720512401.jpg\" class=\"aligncenter\" title=\"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\u63d2\u56fe\" alt=\"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\u63d2\u56fe\" \/><\/p>\n<p><strong> compose \u65e0\u6cd5\u90e8\u7f72 <\/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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5bfc\u81f4\u542f\u52a8\u65f6\u627e\u4e0d\u5230 \/etc\/mysql\/conf.d \u76ee\u5f55\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fDocker Compose \u90e8\u7f72 MySQL \u5931\u8d25\uff1a\u4e3a\u4f55\u51fa\u73b0 \u201cd: Can&#8217;t read dir of &#8216;\/etc\/mysql\/conf.d\/&#8217;\u201d \u9519\u8bef\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>compose \u65e0\u6cd5\u90e8\u7f72 \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 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 \u91c7\u53d6\u4e86\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u6ce8\u91ca\u6389\u6302\u8f7d\uff0c\u76f4\u63a5\u542f\u52a8 mysql\uff0c\u6210\u529f\u542f\u52a8\u3002 \u5c06\u5bb9\u5668\u4e2d\u7684 \/var\/lib\/mysql \u590d\u5236\u5230\u5bbf\u4e3b\u673a\u6307\u5b9a\u6302\u8f7d\u76ee\u5f55\u3002 \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 \u5220\u9664\u955c\u50cf\u3002 \u6253\u5f00\u6302\u8f7d\u6ce8\u91ca\u3002 \u6b64\u65f6\u51fa\u73b0\u9519\u8bef\uff1a [&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-7813","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7813","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=7813"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7813\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}