{"id":63742,"date":"2025-04-29T08:12:44","date_gmt":"2025-04-29T00:12:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63742\/"},"modified":"2025-04-29T08:12:44","modified_gmt":"2025-04-29T00:12:44","slug":"docker%e6%80%8e%e4%b9%88%e5%90%af%e5%8a%a8mysql-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63742\/","title":{"rendered":"docker\u600e\u4e48\u542f\u52a8mysql"},"content":{"rendered":"<blockquote><p>\n  \u5728 docker \u4e2d\u542f\u52a8 mysql \u7684\u8fc7\u7a0b\u5305\u542b\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u62c9\u53d6 mysql \u955c\u50cf\u521b\u5efa\u5e76\u542f\u52a8\u5bb9\u5668\uff0c\u8bbe\u7f6e\u6839\u7528\u6237\u5bc6\u7801\u5e76\u6620\u5c04\u7aef\u53e3\u9a8c\u8bc1\u8fde\u63a5\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\u6388\u4e88\u5bf9\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/05\/2024060505211739972.jpg\" class=\"aligncenter\" title=\"docker\u600e\u4e48\u542f\u52a8mysql\u63d2\u56fe\" alt=\"docker\u600e\u4e48\u542f\u52a8mysql\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Docker \u4e2d\u542f\u52a8 MySQL<\/strong><\/p>\n<p>\u5728 Docker \u4e2d\u542f\u52a8 MySQL \u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u5b83\u63d0\u4f9b\u4e86\u5728\u9694\u79bb\u548c\u53ef\u79fb\u690d\u7684\u73af\u5883\u4e2d\u8fd0\u884c MySQL \u7684\u4e00\u79cd\u4fbf\u6377\u65b9\u5f0f\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u62c9\u53d6 MySQL \u955c\u50cf\uff1a<\/strong><\/p>\n<pre>docker pull mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u521b\u5efa\u5e76\u542f\u52a8\u5bb9\u5668\uff1a<\/strong><\/p>\n<pre>docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=your_password -p 3306:3306 mysql<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>-d \u6807\u5fd7\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u6a21\u5f0f\u8fd0\u884c\u5bb9\u5668<\/li>\n<li>&#8211;name  \u4e3a\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0<\/li>\n<li>-e MYSQL_ROOT_PASSWORD=your_password \u8bbe\u7f6e MySQL \u6839\u7528\u6237\u7684\u5bc6\u7801<\/li>\n<li>-p 3306:3306 \u5c06\u5bb9\u5668\u5185\u7684\u7aef\u53e3 3306 \u6620\u5c04\u5230\u4e3b\u673a\u7684\u7aef\u53e3 3306<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u8fde\u63a5\uff1a<\/strong><br \/>\u7b49\u5f85\u5bb9\u5668\u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u8fde\u63a5\uff1a<\/p>\n<pre>docker exec -it mysql mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\uff1a<\/strong><br \/>\u8fde\u63a5\u5230 MySQL \u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\uff1a<\/p>\n<pre>CREATE DATABASE your_database;\nCREATE USER 'your_username'@'%' IDENTIFIED BY 'your_password';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u6388\u4e88\u6743\u9650\uff1a<\/strong><br \/>\u6700\u540e\uff0c\u6388\u4e88\u65b0\u7528\u6237\u5bf9\u65b0\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\uff1a<\/p>\n<pre>GRANT ALL PRIVILEGES ON your_database.* TO 'your_username'@'%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p>\u73b0\u5728\uff0c\u60a8\u5df2\u7ecf\u6210\u529f\u5728 Docker \u4e2d\u542f\u52a8\u5e76\u914d\u7f6e\u4e86 MySQL\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u542f\u52a8\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 docker \u4e2d\u542f\u52a8 mysql \u7684\u8fc7\u7a0b\u5305\u542b\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u62c9\u53d6 mysql \u955c\u50cf\u521b\u5efa\u5e76\u542f\u52a8\u5bb9\u5668\uff0c\u8bbe\u7f6e\u6839\u7528\u6237\u5bc6\u7801\u5e76\u6620\u5c04\u7aef\u53e3\u9a8c\u8bc1\u8fde\u63a5\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\u6388\u4e88\u5bf9\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650 \u5982\u4f55\u5728 Docker \u4e2d\u542f\u52a8 MySQL \u5728 Docker \u4e2d\u542f\u52a8 MySQL \u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u5b83\u63d0\u4f9b\u4e86\u5728\u9694\u79bb\u548c\u53ef\u79fb\u690d\u7684\u73af\u5883\u4e2d\u8fd0\u884c MySQL \u7684\u4e00\u79cd\u4fbf\u6377\u65b9\u5f0f\u3002 \u6b65\u9aa4\uff1a \u62c9\u53d6 MySQL \u955c\u50cf\uff1a docker pull mysql \u767b\u5f55\u540e\u590d\u5236 \u521b\u5efa\u5e76\u542f\u52a8\u5bb9\u5668\uff1a docker run -d &#8211;name mysql -e MYSQL_ROOT_PASSWORD=your_password -p 3306:3306 mysql \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a -d \u6807\u5fd7\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u6a21\u5f0f\u8fd0\u884c\u5bb9\u5668 &#8211;name \u4e3a\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0 -e MYSQL_ROOT_PASSWORD=your_password \u8bbe\u7f6e MySQL \u6839\u7528\u6237\u7684\u5bc6\u7801 -p 3306:3306 \u5c06\u5bb9\u5668\u5185\u7684\u7aef\u53e3 3306 \u6620\u5c04\u5230\u4e3b\u673a\u7684\u7aef\u53e3 3306 \u9a8c\u8bc1\u8fde\u63a5\uff1a\u7b49\u5f85\u5bb9\u5668\u542f\u52a8\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u8fde\u63a5\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63742","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63742","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=63742"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63742\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}