{"id":76,"date":"2011-09-08T22:27:19","date_gmt":"2011-09-08T14:27:19","guid":{"rendered":"http:\/\/www.withonly.com\/?p=76"},"modified":"2011-09-08T22:37:26","modified_gmt":"2011-09-08T14:37:26","slug":"mongodb%e8%af%95%e7%8e%a9","status":"publish","type":"post","link":"https:\/\/blog.5danyuan.com\/?p=76","title":{"rendered":"Mongodb\u8bd5\u73a9"},"content":{"rendered":"<p>\u6700\u65e9\u662f\u6709\u770b\u5230\u67d0\u5f00\u6e90\u7f51\u7ad9\u4e0a\u6709\u4ecb\u7ecd NoSQL\uff0c\u7785\u4e86\u51e0\u773c\uff0c\u540e\u6765 stephen \u5728\u67d0\u5929\u4e5f\u5c0f\u804a\u4e86\u51e0\u53e5\uff0c\u518d\u5c31\u662f\u540e\u6765\u4ece\u67d0\u524d\u7aef\u7fa4\u91cc\u987a\u4fbf\u770b\u5230\u4e86<a href=\"http:\/\/blog.zhaojie.me\">\u67d0\u4eba<\/a>\u7684\u535a\u5ba2\u91cc\u53d1\u73b0\u4e86\u76db\u5927\u7684\u9ea6\u5e93\u662f\u7528\u7684Mongodb\u505a\u7684\u3002\u89c9\u5f97\u8fd9\u4e1c\u897f\u53ef\u4ee5\u53bb\u770b\u4e00\u770b\u4e86\u3002<\/p>\n<p>\u9996\u5148\u53bb <a href=\"http:\/\/www.mongodb.org\/downloads\">http:\/\/www.mongodb.org\/downloads<\/a> \u4e0b\u8f7d\u7a33\u5b9a\u7248\u7684 windows \u5305\uff0c\u539f\u8c05\u6211\u5bf9 linux \u7cfb\u7edf\u7684\u4e0d\u719f\u6089\uff0c\u4f8b\u5982\u89e3\u5305\u7684\u547d\u4ee4\u4e00\u4e0d\u770b\u5c31\u5bb9\u6613\u5fd8\u8bb0\uff0c\u5012\u662f\u521d\u4e2d\u65f6\u770b\u7684 Dos \u547d\u4ee4\u4e0d\u5bb9\u6613\u5fd8\u8bb0\u3002<\/p>\n<p>\u6309\u7167\u7f51\u4e0a\u7684\u6559\u7a0b\uff0c\u5148\u5f00\u4e2acmd \u8bbe\u7f6e\u6570\u636e\u5e93\u7684\u5b58\u653e\u8def\u5f84\u3002\u547d\u4ee4\u662f\u8fd9\u6837\u7684 mongod.exe &#8211;dbpath=&#8221;G:\\mongo&#8221;\uff0c\u56de\u8f66\u540e\u4e0d\u8981\u5173\u95ed\u8fd9\u4e2a\u547d\u4ee4\u884c\uff0c\u4ece\u754c\u9762\u7684\u8f93\u51fa\u53ef\u4ee5\u770b\u5230\u9ed8\u8ba4\u7684\u7aef\u53e3\u53f7\u4e3a 27017 \u3002<\/p>\n<p>\u63a5\u7740\u518d\u53e6\u5916\u5f00\u4e00\u4e2a cmd \uff0c\u8f93\u5165 mongo.exe \u3002\u5269\u4e0b\u7684\u5c31\u662f\u81ea\u5df1\u6478\u7d22\u7740\u73a9\u4e86\u3002\u6211\u6536\u96c6\u4e86\u51e0\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\uff0c\u5927\u5bb6\u53ef\u4ee5\u7785\u4e00\u773c\uff1a<\/p>\n<p>show dbs; \u663e\u793a\u6240\u6709\u7684\u6570\u636e\u5e93<\/p>\n<p>var me={name:&#8221;\u8863\u670d\u81ea\u5df1\u6d17&#8221;,version:1};\u8bbe\u7f6e\u8981\u6dfb\u52a0\u7684\u5185\u5bb9\uff0c\u8fd9\u53ef\u662fBSON\u683c\u5f0f\u7684\u5594<\/p>\n<p>db.withonly.save(me);\u4fdd\u5b58\u4fe1\u606f\u5230\u8868\u4e2d<\/p>\n<p>db.withonly.find().forEach(printjson);\u8f93\u51fa\u6240\u6709\u7684\u4fe1\u606f<\/p>\n<p>db.withonly.findOne({version:1});\u67e5\u627e\u6307\u5b9a\u7684\u4e00\u6761\u8bb0\u5f55\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u8981\u505a\u7684\u4e8b\u60c5\u5c31\u662f\u627e\u627e C#\u3001Php\u53ef\u4ee5\u7528\u7684\u9a71\u52a8\u54af\u3002\u5176\u5b9e\u6211\u5bf9\u8fd9\u4e2a\u4e1c\u897f\u597d\u5947\u7684\u539f\u56e0\u662f\u5728\u4e8e\u4e0d\u60f3\u4e70\u6570\u636e\u5e93\uff0c\u6bcf\u5e74\u6570\u636e\u5e93\u90fd\u8981\u989d\u5916\u7684\u82b1500\u591a\uff0c\u5f88\u662f\u5fc3\u75bc\u5440\uff0c\u4e8e\u662f\u5c31\u60f3\u5982\u679c\u6709\u4ec0\u4e48\u6280\u672f\u53ef\u4ee5\u4e0d\u7528\u6570\u636e\u5e93\u4fdd\u5b58\u4fe1\u606f\u5c31\u597d\u4e86\u3002\u4eca\u5929\u628a\u5305\u4e00\u4e0b\u8f7d\u5c31\u53d1\u73b0\u574f\u4e8b\u4e86\uff0c\u865a\u62df\u7a7a\u95f4\u6839\u672c\u5c31\u4e0d\u5141\u8bb8\u8dd1\u8fd9\u6837\u7684\u73a9\u610f\u7684\uff0c\u8fd8\u522b\u8bf4\u6709\u4e2a\u7aef\u53e3\u7684\u3002\u5230\u6700\u540e\u4f30\u8ba1\u4e5f\u5c31 SQLite \u7b26\u5408\u6211\u7684\u8981\u6c42\u4e86\u3002\u6211\u5728\u60f3\u5565\u65f6\u5019\u5728\u4e70\u7684\u90a3\u4e2a UPS \u4e0a\u7ed9\u5b9e\u9a8c\u4e00\u628a\u3002<\/p>\n<p>\u7f51\u4e0a\u5e94\u8be5\u6709\u505a\u6210\u7cfb\u7edf\u670d\u52a1\u7684\u65b9\u5f0f\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u5f00\u591a\u4e2a\u547d\u4ee4\u884c\u4e86\u3002\u4e0d\u8fc7\u6211\u7535\u8111\u91cc\u7684\u670d\u52a1\u5df2\u7ecf\u591f\u591a\u4e86\uff0c\u670d\u52a1\u7684\u65b9\u5f0f\u5c31\u4e0d\u81ea\u5df1\u5c1d\u8bd5\u4e86\uff0c\u7559\u5230 Linux \u4e0a\u7528\u5427\u3002<\/p>\n<p>\u5199\u5230\u8fd9\u91cc\u4e5f\u5c31\u8bf4\u4e2a\u9898\u5916\u8bdd\uff0c\u5728\u770b\u9ea6\u5e93\u7684\u65f6\u5019\uff0c\u6211\u4e60\u60ef\u770b\u4e86\u4e0b\u4eba\u5bb6\u7684 html \u6e90\u6587\u4ef6\uff0c\u53d1\u73b0\u6709\u7c7b\u4f3c\u8fd9\u6837\u7684\u5199\u6cd5\uff1a&lt;link rel=&#8221;stylesheet&#8221; href=&#8221;<a href=\"http:\/\/note.sdo-static.com\/p?static\/css\/global~note.reset_2,global~note.portal.global_1,global~note.portal.header_1,global~note.portal.footer_1,pages~note.home_3.css\">http:\/\/note.sdo-static.com\/p?static\/css\/global~note.reset_2,global~note.portal.global_1.css<\/a>&#8221; \/&gt;\u548c&lt;script src=&#8221;<a href=\"http:\/\/note.sdo-static.com\/p?static\/js\/lib~j_1,lib~g_1,lib~j.cookie_1,lib~j.ui.core_1,lib~j.ui.widget_1,lib~j.ui.mouse_1,lib~j.ui.position_1,pages~home~note.index_2,pages~note.layer_1,pages~home~note.sndaoswidget_1.js&quot;><\/script\">http:\/\/note.sdo-static.com\/p?static\/js\/lib~j_1,lib~g_1.js&#8221;&gt;&lt;\/script<\/a>&gt;\u83ab\u975e\u8fd9\u4e2a\u5c31\u662f\u90a3\u5565\uff0c\u8fd9\u4e2a\u601d\u60f3\u6211\u8fd8\u6728\u6709\u7528\u5230\u5b9e\u9645\u7684\u9879\u76ee\u4e2d\u53bb\u5462\u3002\u4ee5\u540e\u6709\u673a\u4f1a\u7528\u4e00\u4e0b\u3002<\/p>\n<p>\u6c42\u5de5\u4f5c\uff0c\u6c42\u4eba\u54c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u65e9\u662f\u6709\u770b\u5230\u67d0\u5f00\u6e90\u7f51\u7ad9\u4e0a\u6709\u4ecb\u7ecd NoSQL\uff0c\u7785\u4e86\u51e0\u773c\uff0c\u540e\u6765 stephen \u5728\u67d0\u5929\u4e5f\u5c0f\u804a\u4e86\u51e0\u53e5\uff0c\u518d\u5c31\u662f\u540e\u6765\u4ece\u67d0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[23],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-daily","tag-nosql"],"_links":{"self":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":0,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.5danyuan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}