{"id":461,"date":"2023-02-25T13:29:20","date_gmt":"2023-02-25T05:29:20","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=461"},"modified":"2023-04-29T20:58:05","modified_gmt":"2023-04-29T12:58:05","slug":"install-and-config-mongodb-under-windows","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/install-and-config-mongodb-under-windows\/","title":{"rendered":"Windows\u4e0b\u5b89\u88c5\u914d\u7f6eMongoDB"},"content":{"rendered":"<p>\u5b98\u7f51\u4e0b\u8f7d\uff1a <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.mongodb.com\/download-center\">https:\/\/www.mongodb.com\/download-center<\/a><\/p>\n<p>\u9009\u62e9<code>Community Server<\/code>\u7248\u672c\uff0c\u4e0b\u8f7dzip\u5305\u5373\u53ef<\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>mongod: \u542f\u52a8MongoDB\u670d\u52a1<\/li>\n<li>mongo: MongoDB\u5ba2\u6237\u7aef<\/li>\n<li>mongoimport: \u5bfc\u51fa\u6570\u636e\u5e93<\/li>\n<li>mongoexport: \u5bfc\u5165\u6570\u636e\u5e93<\/li>\n<li>mongodump: \u5907\u4efd\u6570\u636e\u5e93<\/li>\n<li>mongorestore: \u6062\u590d\u6570\u636e\u5e93<\/li>\n<\/ul>\n<p>\uff081\uff09\u542f\u52a8MongoDB\u670d\u52a1<\/p>\n<pre><code>mongod --dbpath D:\\mongo<\/code><\/pre>\n<p>\uff082\uff09\u8fde\u63a5MongoDB<\/p>\n<pre><code>> mongo\nMongoDB shell version v4.0.6\nconnecting to: mongodb:\/\/127.0.0.1:27017\/?gssapiServiceName=mongodb\nImplicit session: session { &quot;id&quot; : UUID(&quot;c31ac25f-b77b-4248-ab5e-b70fc1b48578&quot;) }\nMongoDB server version: 4.0.6\nWelcome to the MongoDB shell.\nFor interactive help, type &quot;help&quot;.\nFor more comprehensive documentation, see\n        http:\/\/docs.mongodb.org\/\nQuestions? Try the support group\n        http:\/\/groups.google.com\/group\/mongodb-user\n\n> show dbs  \/\/\u663e\u793a\u6240\u6709\u7684\u6570\u636e\u5e93\n> use admin  \/\/\u5207\u6362\u5230admin\nswitched to db admin\n> db.createUser({user:&#039;root&#039;,pwd:&#039;root&#039;,roles:[&#039;userAdminAnyDatabase&#039;]})  \/\/\u6dfb\u52a0\u7ba1\u7406\u7528\u6237\nSuccessfully added user: { &quot;user&quot; : &quot;root&quot;, &quot;roles&quot; : [ &quot;userAdminAnyDatabase&quot; ] }\n> db.auth(&#039;root&#039;,&#039;root&#039;)  \/\/\u9a8c\u8bc1\u7ba1\u7406\u7528\u6237\n1\n> use test  \/\/\u518d\u5207\u6362\u6570\u636e\u5e93\uff0c\u5e76\u6dfb\u52a0\u7528\u6237\nswitched to db test\n> db.createUser({user:&#039;test&#039;,pwd:&#039;123456&#039;,roles:[&#039;readWrite&#039;]})\nSuccessfully added user: { &quot;user&quot; : &quot;test&quot;, &quot;roles&quot; : [ &quot;readWrite&quot; ] }\n><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u7f51\u4e0b\u8f7d\uff1a https:\/\/www.mongodb.com\/download-center \u9009\u62e9Communi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[154],"class_list":["post-461","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-mongodb"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=461"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/461\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}