{"id":2966,"date":"2023-11-12T09:38:39","date_gmt":"2023-11-12T01:38:39","guid":{"rendered":"https:\/\/104.es\/?p=2966"},"modified":"2023-11-12T09:38:42","modified_gmt":"2023-11-12T01:38:42","slug":"docker-mysql-wordpress-phpmyadmin","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2023\/11\/12\/docker-mysql-wordpress-phpmyadmin\/","title":{"rendered":"\u4f7f\u7528Docker\u90e8\u7f72MySQL+WordPress+phpMyAdmin"},"content":{"rendered":"\n<p>\u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\u6211\u5011\u793a\u7bc4\u4e86\u5982\u4f55\u4f7f\u7528docker-compose\u6307\u4ee4\u90e8\u7f72MySQL\u52a0\u4e0aWordPress\uff0c\u8b93\u6211\u5011\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5728\u4efb\u4f55\u4e00\u53f0\u96fb\u8166\u6216\u4f3a\u670d\u5668\u4e0a\u628aWordPress\u5feb\u901f\u67b6\u8d77\u4f86\uff0c\u4f46\u662f\uff0c\u53ea\u6709WordPress\u5c0d\u65bc\u6709\u6642\u5019\u8981\u9032\u884c\u8cc7\u6599\u5eab\u7ba1\u7406\u7684\u7ad9\u9577\u4f86\u8aaa\u4e26\u4e0d\u592a\u65b9\u4fbf\u3002\u56e0\u6b64\uff0c\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u518d\u4f86\u5beb\u4e00\u6bb5docker-compose.yml\uff0c\u628aphpMyAdmin\u4e5f\u52a0\u4e0a\u53bb\u3002<\/p>\n\n\n\n<p>\u5728\u9019\u88e1\u6211\u5011\u4ee5Windows\u4f5c\u696d\u7cfb\u7d71\u70ba\u4f8b\uff0c\u7576\u7136\uff0c\u5728\u4f5c\u696d\u7cfb\u7d71\u4e2d\uff0c\u4e00\u958b\u59cb\u7684Docker Desktop for Windows\u662f\u4e00\u5b9a\u8981\u5148\u5b89\u88dd\u597d\u7684\u3002\u8acb\u5efa\u7acb\u4e00\u500b\u8cc7\u6599\u593e\uff0c\u7136\u5f8c\u5728\u8a72\u8cc7\u6599\u593e\u4e2d\u5efa\u7acb\u4e00\u500b\u53eb\u505adocker-compose.yml\u7684\u6a94\u6848\uff0c\u5176\u6a94\u6848\u7684\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">version: '3.9'\r\n\r\nservices:\r\n  db:\r\n    image: mysql:latest\r\n    volumes:\r\n      - .\/mysql:\/var\/lib\/mysql\r\n    restart: always\r\n    environment:\r\n      MYSQL_ROOT_PASSWORD: 12345678\r\n      MYSQL_DATABASE: wpdb\r\n      MYSQL_USER: wpadmin\r\n      MYSQL_PASSWORD: 12345678\r\n\r\n  wordpress:\r\n    depends_on:\r\n      - db\r\n    image: wordpress:latest\r\n    ports:\r\n      - \"8080:80\"\r\n    volumes:\r\n      - .\/wp:\/var\/www\/html\r\n    restart: always\r\n    environment:\r\n      WORDPRESS_DB_HOST: db:3306\r\n      WORDPRESS_DB_USER: wpadmin\r\n      WORDPRESS_DB_PASSWORD: 12345678\r\n      WORDPRESS_DB_NAME: wpdb\r\n\r\n  phpmyadmin:\r\n    depends_on:\r\n      - db\r\n    image: phpmyadmin\/phpmyadmin:latest\r\n    ports:\r\n      - \"8081:80\"\r\n    environment:\r\n      PMA_HOST: db\r\n      MYSQL_ROOT_PASSWORD: 12345678\r\n<\/code><\/pre>\n\n\n\n<p>\u5728\u9019\u500b\u6a94\u6848\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u76ee\u524d\u8cc7\u6599\u593e\u5e95\u4e0b\u7684mysql\u8cc7\u6599\u593e\u5c0d\u61c9\u5230MySQL\u7684\u8cc7\u6599\u5eab\u6a94\u6848\uff0c\u4f7f\u7528wp\u8cc7\u6599\u593e\u5c0d\u61c9\u5230WordPress\u7684\u8cc7\u6599\u6a94\u6848\u3002\u81f3\u65bcphpMyAdmin\u7684\u5e33\u865f\u5247\u662froot\uff0c\u5bc6\u78bc\u5247\u662f12345678\u3002\u8acb\u4f7f\u7528\u4ee5\u4e0b\u7684\u6307\u4ee4\u57f7\u884c\u670d\u52d9\u7684\u90e8\u7f72\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">docker-compose up -d<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u5be6\u969b\u57f7\u884c\u7684\u8a0a\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">D:\\wordpress> docker-compose up -d\r\n[+] Running 4\/4\r\n - Network wordpress_default         Created                                                                                                                                                    0.8s \r\n - Container wordpress-db-1          Started                                                                                                                                                    1.3s\r\n - Container wordpress-phpmyadmin-1  Started                                                                                                                                                    3.3s \r\n - Container wordpress-wordpress-1   Started <\/code><\/pre>\n\n\n\n<p>\u9019\u6642\u5019\uff0c\u6211\u5011\u7684WordPress\u7684\u7db2\u7ad9\u5c31\u6703\u88ab\u958b\u5728\u57e0\u865f8080\uff0c\u800cphpMyAdmin\u5247\u88ab\u958b\u5728\u57e0\u865f8081\u3002\u7576\u670d\u52d9\u88ab\u9806\u5229\u555f\u7528\u4e4b\u5f8c\uff0c\u4ee5\u9019\u500b\u4f8b\u5b50\uff0c\u5728D:\\wordpress\u8cc7\u6599\u593e\u5e95\u4e0b\u5c31\u6703\u591a\u4e86\u5169\u500b\u8cc7\u6599\u593e\uff0c\u4f7f\u7528dir\u6307\u4ee4\u7684\u6aa2\u8996\u7d50\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS D:\\wordpress> dir\r\n\r\n\n    Directory: D:\\wordpress\r\n\r\n\r\nMode                 LastWriteTime         Length Name\r\n----                 -------------         ------ ----\r\nda----        2023\/11\/10  \u4e0b\u5348 04:56                mysql\r\n\r\nda----        2023\/11\/10  \u4e0b\u5348 04:57                wp\r\n\r\n-a----        2023\/11\/10  \u4e0b\u5348 04:41            789 docker-compose.yml<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4e0d\u60f3\u4f7f\u7528\u9019\u500b\u670d\u52d9\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528docker-compose down\uff0c\u57f7\u884c\u4e4b\u8a0a\u606f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS D:\\wordpress> docker-compose down \r\n[+] Running 4\/4\r\n - Container wordpress-phpmyadmin-1  Removed                                                                                                                                                    1.7s \r\n - Container wordpress-wordpress-1   Removed                                                                                                                                                    1.7s \r\n - Container wordpress-db-1          Removed                                                                                                                                                    1.5s\r\n - Network wordpress_default         Removed  <\/code><\/pre>\n\n\n\n<p>\u7531\u65bc\u6240\u6709\u7684\u8cc7\u6599\u90fd\u88ab\u653e\u5728mysql\u548cwp\u8cc7\u6599\u593e\u4e4b\u4e0b\uff0c\u6240\u4ee5\u4e0b\u6b21\u91cd\u65b0\u555f\u7528\u4f3a\u670d\u5668\u6642\uff0c\u6240\u6709\u4e4b\u524d\u5efa\u7acb\u904e\u7684\u8a2d\u5b9a\u90fd\u9084\u6703\u88ab\u4fdd\u7559\u4e0b\u4f86\u3002\u5982\u679c\u4f60\u60f3\u8981\u628a\u7db2\u7ad9\u642c\u5230\u5225\u53f0\u6a5f\u5668\uff0c\u4e5f\u53ea\u8981\u628a\u9019\u4e9b\u6a94\u6848\u901a\u901a\u8907\u88fd\u904e\u53bb\uff0c\u518d\u5230\u90a3\u53f0\u6a5f\u5668\u4e0a\u57f7\u884c\u4e00\u6b21docker-compose up -d \u9019\u500b\u6307\u4ee4\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p>\u7279\u5225\u8981\u7559\u610f\u7684\u5730\u65b9\u662f\uff0c\u5982\u679c\u4f60\u5df2\u7d93\u57f7\u884c\u904e\u6307\u4ee4\uff0c\u5f8c\u4f86\u53c8\u5728docker-compose.yml\u4e2d\u4fee\u6539\u4e86\u5bc6\u78bc\uff0c\u5f8c\u4f86\u7684\u5bc6\u78bc\u662f\u6c92\u8fa6\u6cd5\u76f4\u63a5\u5957\u7528\uff0c\u8981\u5148\u56de\u5230\u8cc7\u6599\u5eab\u4e2d\u4fee\u6539\u539f\u6709\u7684\u5bc6\u78bc\u8a2d\u5b9a\u624d\u884c\u5594\u3002\u6240\u4ee5\uff0c\u5efa\u8b70\u5927\u5bb6\u4e00\u958b\u59cb\u5c31\u5148\u628a\u5bc6\u78bc\u60f3\u597d\uff0c\u518d\u958b\u59cb\u57f7\u884c\u6307\u4ee4\uff0c\u9019\u6a23\u53ef\u4ee5\u7701\u53bb\u5f88\u591a\u9ebb\u7169\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u524d\u9762\u7684\u6587\u7ae0\u4e2d\u6211\u5011\u793a\u7bc4\u4e86\u5982\u4f55\u4f7f\u7528docker-compose\u6307\u4ee4\u90e8\u7f72MySQL\u52a0\u4e0aWordPress\uff0c\u8b93\u6211\u5011\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5728\u4efb\u4f55\u4e00\u53f0\u96fb\u8166\u6216\u4f3a\u670d\u5668\u4e0a\u628aWordPress\u5feb\u901f\u67b6\u8d77\u4f86\uff0c\u4f46\u662f\uff0c\u53ea\u6709WordPress\u5c0d\u65bc\u6709\u6642\u5019\u8981\u9032\u884c\u8cc7\u6599\u5eab\u7ba1\u7406\u7684\u7ad9\u9577\u4f86\u8aaa\u4e26\u4e0d\u592a\u65b9\u4fbf\u3002\u56e0\u6b64\uff0c\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u518d\u4f86\u5beb\u4e00\u6bb5docker-compose.yml\uff0c\u628aphpMyAdmin\u4e5f\u52a0\u4e0a\u53bb\u3002<\/p>\n","protected":false},"author":1,"featured_media":2968,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7,19],"tags":[30,32,47,49,70],"class_list":["post-2966","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-wordpress","tag-docker","tag-docker-compose","tag-mysql","tag-phpmyadmin","tag-wordpress"],"jetpack_featured_media_url":"https:\/\/104.es\/wp-content\/uploads\/2023\/11\/11.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=2966"}],"version-history":[{"count":2,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2966\/revisions"}],"predecessor-version":[{"id":2969,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2966\/revisions\/2969"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media\/2968"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}