{"id":6209,"date":"2017-05-23T09:50:21","date_gmt":"2017-05-23T01:50:21","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6209"},"modified":"2017-05-23T09:50:21","modified_gmt":"2017-05-23T01:50:21","slug":"%e5%a4%87%e4%bb%bddocker%e5%ae%b9%e5%99%a8%e4%b8%ad%e7%9a%84mysql%e5%92%8cmongodb","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6209.html","title":{"rendered":"\u5907\u4efdDocker\u5bb9\u5668\u4e2d\u7684MySQL\u548cMongoDB"},"content":{"rendered":"<p>\u5047\u8bbe\u73b0\u5728\u4f60\u8fd0\u884c\u4e86\u4e00\u4e2a\u53eb mongodb \u7684container\uff0c\u9700\u8981\u5907\u4efd\u5230 \/tmp\/mongodb \u76ee\u5f55\u4e0b\u9762\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ docker run \\\r\n --rm \\\r\n --link mongodb:mongo \\\r\n -v \/tmp\/mongodb:\/tmp \\\r\n mongo \\\r\n bash -c 'mongodump --out \/tmp --host $MONGO_PORT_27017_TCP_ADDR'\r\n<\/pre>\n<p>\u6062\u590d<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n $ docker run \\\r\n --rm \\\r\n --link mongodb:mongo \\\r\n -v \/tmp\/mongodb:\/backup \\\r\n mongo \\\r\n bash -c 'mongorestore \/backup --host $MONGO_PORT_27017_TCP_ADDR'\r\n<\/pre>\n<p>\u5907\u4efdMySQL<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndocker exec CONTAINER \/usr\/bin\/mysqldump -u root --password=root DATABASE &gt; backup.sql\r\n<\/pre>\n<p>\u6062\u590dMySQL<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncat backup.sql | docker exec -i CONTAINER \/usr\/bin\/mysql -u root --password=root DATABASE\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5047\u8bbe\u73b0\u5728\u4f60\u8fd0\u884c\u4e86\u4e00\u4e2a\u53eb mongodb \u7684container\uff0c\u9700\u8981\u5907\u4efd\u5230 \/tmp\/mongodb \u76ee\u5f55\u4e0b\u9762\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6209","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6209"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6209\/revisions"}],"predecessor-version":[{"id":6210,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6209\/revisions\/6210"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}