{"id":7565,"date":"2024-11-14T10:45:08","date_gmt":"2024-11-14T02:45:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7565\/"},"modified":"2024-11-14T10:45:08","modified_gmt":"2024-11-14T02:45:08","slug":"docker-hub-mysql-%e4%b8%ad%e5%a6%82%e4%bd%95%e8%87%aa%e5%ae%9a%e4%b9%89%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e6%8c%87%e5%ae%9a-mysql-%e5%ad%97%e7%ac%a6%e9%9b%86%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7565\/","title":{"rendered":"Docker Hub MySQL \u4e2d\u5982\u4f55\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a MySQL \u5b57\u7b26\u96c6\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173099152796529.jpg\" class=\"aligncenter\" title=\"Docker Hub MySQL \u4e2d\u5982\u4f55\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a MySQL \u5b57\u7b26\u96c6\uff1f\u63d2\u56fe\" alt=\"Docker Hub MySQL \u4e2d\u5982\u4f55\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a MySQL \u5b57\u7b26\u96c6\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u901a\u8fc7\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a  \u5b57\u7b26\u96c6<\/strong><\/p>\n<p>\u5728 \u201c hub mysql\u201d \u4e2d\u63d0\u4f9b\u7684\u4f8b\u5b50\u672a\u80fd\u6210\u529f\u6307\u5b9a mysql \u5b57\u7b26\u96c6\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3\uff1a<\/p>\n<p>\u5728\u5bbf\u4e3b\u673a\u4e0a\u521b\u5efa\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u968f\u610f\uff0c\u540e\u7f00\u4e3a .cnf\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>$ vim character_set.cnf<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre>[mysqld]\ncharacter-set-server = utf8mb4\n[client]\ndefault-character-set = utf8mb4\n[mysql]\ndefault-character-set = utf8mb4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/p>\n<p>\u542f\u52a8\u5bb9\u5668\u65f6\uff0c\u6302\u8f7d\u8be5\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u5230\u5bb9\u5668\u7684 \/etc\/mysql\/conf.d \u76ee\u5f55\uff1a<\/p>\n<pre>$ docker run \n    --name mysql \n    -v \/path\/to\/cusotm:\/etc\/mysql\/conf.d \n    -e mysql_root_password=my-secret-pw \n    -d mysql:tag<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u542f\u52a8\u5b8c\u6210\u540e\uff0c\u8fdb\u5165\u5bb9\u5668\u5e76\u767b\u5f55 mysql\uff0c\u68c0\u67e5\u5b57\u7b26\u96c6\u8bbe\u7f6e\uff1a<\/p>\n<pre>$ show variables like '%char%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u5b57\u7b26\u96c6\u5df2\u6b63\u786e\u8bbe\u7f6e\u4e3a utf8mb4\u3002<\/p>\n<p>\u6b64\u65b9\u6cd5\u901a\u8fc7\u8986\u76d6\u5bb9\u5668\u5185\u90e8\u7684 mysql \u914d\u7f6e\u6587\u4ef6\u6765\u5b9e\u73b0\u5b57\u7b26\u96c6\u7684\u6307\u5b9a\u3002\u6709\u5173 mysql \u5b57\u7b26\u96c6\u8bbe\u7f6e\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003 [mysql \u6587\u6863](https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/charset-unicode-sets.html)\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fDocker Hub MySQL \u4e2d\u5982\u4f55\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a MySQL \u5b57\u7b26\u96c6\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>\u901a\u8fc7\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6307\u5b9a \u5b57\u7b26\u96c6 \u5728 \u201c hub mysql\u201d \u4e2d\u63d0\u4f9b\u7684\u4f8b\u5b50\u672a\u80fd\u6210\u529f\u6307\u5b9a mysql \u5b57\u7b26\u96c6\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3\uff1a \u5728\u5bbf\u4e3b\u673a\u4e0a\u521b\u5efa\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u968f\u610f\uff0c\u540e\u7f00\u4e3a .cnf\u3002\u4f8b\u5982\uff1a $ vim character_set.cnf \u767b\u5f55\u540e\u590d\u5236 \u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230\u6587\u4ef6\u4e2d\uff1a [mysqld] character-set-server = utf8mb4 [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 \u767b\u5f55\u540e\u590d\u5236 \u4fdd\u5b58\u5e76\u9000\u51fa\u3002 \u542f\u52a8\u5bb9\u5668\u65f6\uff0c\u6302\u8f7d\u8be5\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u5230\u5bb9\u5668\u7684 \/etc\/mysql\/conf.d \u76ee\u5f55\uff1a $ docker run &#8211;name mysql -v \/path\/to\/cusotm:\/etc\/mysql\/conf.d -e mysql_root_password=my-secret-pw -d mysql:tag \u767b\u5f55\u540e\u590d\u5236 \u542f\u52a8\u5b8c\u6210\u540e\uff0c\u8fdb\u5165\u5bb9\u5668\u5e76\u767b\u5f55 mysql\uff0c\u68c0\u67e5\u5b57\u7b26\u96c6\u8bbe\u7f6e\uff1a $ show variables like &#8216;%char%&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u53ef\u4ee5\u770b\u5230\u5b57\u7b26\u96c6\u5df2\u6b63\u786e\u8bbe\u7f6e\u4e3a utf8mb4\u3002 [&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-7565","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7565","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=7565"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7565\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}