{"id":1211,"date":"2024-07-17T12:45:30","date_gmt":"2024-07-17T03:45:30","guid":{"rendered":"https:\/\/absol.kr\/?p=1211"},"modified":"2024-07-17T12:45:30","modified_gmt":"2024-07-17T03:45:30","slug":"mongodb-%ea%b5%ac%ec%84%b1%ea%b3%bc-%ec%82%ac%ec%9a%a9%ec%9e%90-%ec%b6%94%ea%b0%80","status":"publish","type":"post","link":"https:\/\/absol.kr\/?p=1211","title":{"rendered":"MongoDB \uad6c\uc131\uacfc \uc0ac\uc6a9\uc790 \ucd94\uac00"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">MongoDB&nbsp;\uad6c\uc131<\/h2>\n\n\n\n<p>MongoDB&nbsp;\uad6c\uc131 \ud30c\uc77c\uc740&nbsp;\/etc&nbsp;\ub514\ub809\ud1a0\ub9ac\uc5d0 \uc788\uc73c\uba70&nbsp;mongod.conf\ub77c\ub294 \uc774\ub984\uc744 \uac00\uc9c0\uace0 \uc788\uc2b5\ub2c8\ub2e4.&nbsp;\ud30c\uc77c\uc740&nbsp;YAML&nbsp;\ud615\uc2dd\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\uae30\ubcf8 \uad6c\uc131 \uc124\uc815\uc740 \ub300\ubd80\ubd84\uc758 \uacbd\uc6b0\uc5d0 \ucda9\ubd84\ud569\ub2c8\ub2e4.&nbsp;\uadf8\ub7ec\ub098 \uc6b4\uc601 \ud658\uacbd\uc758 \uacbd\uc6b0 \ub2e4\uc74c\uacfc \uac19\uc774 \ubcf4\uc548 \uc139\uc158\uc758 \ubcf4\uc644\uc744 \ud574\uc81c\ud558\uace0 \uc561\uc138\uc2a4 \uc81c\uc5b4\ub97c \uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762496521\" class=\"wp-block-code\"><code>sudo nano \/etc\/mongod.conf\n\n# \/etc\/mongod.conf\n# security:\n#  authorization: enabled<\/code><\/pre>\n\n\n\n<p>\uad8c\ud55c \ubd80\uc5ec \uc635\uc158\uc740 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ub9ac\uc18c\uc2a4 \ubc0f \uc791\uc5c5\uc5d0 \ub300\ud55c \uc0ac\uc6a9\uc790\uc758 \uc561\uc138\uc2a4\ub97c \uaddc\uc81c\ud558\ub294 \uc5ed\ud560 \uae30\ubc18 \uc561\uc138\uc2a4 \uc81c\uc5b4(RBAC)\ub97c \ud65c\uc131\ud654\ud569\ub2c8\ub2e4.&nbsp;\uc774 \uc635\uc158\uc744 \ud65c\uc131\ud654\ud558\uc9c0 \uc54a\uc73c\uba74 \uac01 \uc0ac\uc6a9\uc790\ub294 \ubaa8\ub4e0 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \uc561\uc138\uc2a4\ud560 \uc218 \uc788\uc73c\uba70 \ubaa8\ub4e0 \uc791\uc5c5\uc744 \uc218\ud589\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\uad6c\uc131\uc744 \ubcc0\uacbd\ud560 \ub54c\ub9c8\ub2e4 \ubcc0\uacbd \ub0b4\uc6a9\uc744 \uc801\uc6a9\ud558\ub824\uba74&nbsp;mongod&nbsp;\uc11c\ube44\uc2a4\ub97c \ub2e4\uc2dc \uc2dc\uc791\ud574\uc57c \ud569\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762513520\" class=\"wp-block-code\"><code>sudo systemctl restart mongod<\/code><\/pre>\n\n\n\n<p>\ucd5c\uc2e0&nbsp;MongoDB&nbsp;\ubc84\uc804\uc5d0\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \uad6c\uc131 \uc635\uc158\uc5d0 \ub300\ud55c \uc790\uc138\ud55c \ub0b4\uc6a9\uc740 \uad6c\uc131 \ud30c\uc77c \uc635\uc158 \uc124\uba85\uc11c \ud398\uc774\uc9c0\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uad00\ub9ac&nbsp;MongoDB&nbsp;\uc0ac\uc6a9\uc790 \ub9cc\ub4e4\uae30<\/h2>\n\n\n\n<p>MongoDB&nbsp;\uc778\uc99d\uc744 \uc0ac\uc6a9\ud558\ub3c4\ub85d \uc124\uc815\ud55c \uacbd\uc6b0&nbsp;MongoDB&nbsp;\uc778\uc2a4\ud134\uc2a4\uc5d0 \uc561\uc138\uc2a4\ud558\uace0 \uad00\ub9ac\ud560 \uc218 \uc788\ub294 \uad00\ub9ac \uc0ac\uc6a9\uc790\ub97c \ub9cc\ub4e4\uc5b4\uc57c \ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\ubabd\uace0 \uc178\uc5d0 \uc561\uc138\uc2a4:<\/p>\n\n\n\n<pre id=\"code_1705762584091\" class=\"wp-block-code\"><code>mongosh<\/code><\/pre>\n\n\n\n<p>MongoDB&nbsp;\uc178 \ub0b4\ubd80\uc5d0\uc11c \ub2e4\uc74c \uba85\ub839\uc744 \uc785\ub825\ud558\uc5ec \uad00\ub9ac \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \uc5f0\uacb0\ud569\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762600624\" class=\"wp-block-code\"><code>use admin\n\n# switched to db admin<\/code><\/pre>\n\n\n\n<p>\ub2e4\uc74c \uba85\ub839\uc744 \uc2e4\ud589\ud558\uc5ec \uad00\ub9ac \uc0ac\uc6a9\uc790\ub97c \ub9cc\ub4ed\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762609412\" class=\"wp-block-code\"><code>db.createUser(\n  {\n    user: \"myMongoAdmin\",\n    pwd: passwordPrompt(),\n    roles: &#91;\n      { role: \"userAdminAnyDatabase\", db: \"admin\" },\n      { role: \"readWriteAnyDatabase\", db: \"admin\" }\n    ]\n  }\n)<\/code><\/pre>\n\n\n\n<p>\uad00\ub9ac\uc790 \uc774\ub984\uc744&nbsp;myMongoAdmin\uc774\ub77c\uace0 \uc9c0\uc5c8\uc2b5\ub2c8\ub2e4.&nbsp;\uc6d0\ud558\ub294 \ub300\ub85c \ubd88\ub7ec\uc8fc\uc138\uc694. passwordPrompt()&nbsp;\ubc29\uc2dd \ub300\uc2e0 \uba85\ud655\ud55c \ud14d\uc2a4\ud2b8 \ube44\ubc00\ubc88\ud638\ub97c \uc785\ub825\ud560 \uc218\ub3c4 \uc788\uc9c0\ub9cc,&nbsp;\ube44\ubc00\ubc88\ud638\ub97c \ud654\uba74\uc5d0 \ud45c\uc2dc\ud558\ub294 \uac83\uc740 \uad8c\uc7a5\ub418\uc9c0 \uc54a\uc73c\uba70,&nbsp;\uc258 \uc774\ub825\uc5d0\ub3c4 \uc800\uc7a5\ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\ube44\ubc00\ubc88\ud638\ub97c \uc785\ub825\ud558\uace0 \uc785\ub825 \ud6c4&nbsp;&#8220;Enter&#8221;(\uc785\ub825)\ub97c \ub204\ub974\ub77c\ub294 \uba54\uc2dc\uc9c0\uac00 \ud45c\uc2dc\ub429\ub2c8\ub2e4.&nbsp;\uc548\uc804\ud55c \ube44\ubc00\ubc88\ud638\ub97c \uc124\uc815\ud558\ub294 \uac83\uc744 \uc78a\uc9c0 \ub9c8\uc2ed\uc2dc\uc624:<\/p>\n\n\n\n<pre id=\"code_1705762656257\" class=\"wp-block-code\"><code>Enter password\n\n# ********{ ok: 1 }<\/code><\/pre>\n\n\n\n<p>&#8220;ok: 1&#8243;\uc740 \uba85\ub839\uc774 \uc131\uacf5\uc801\uc73c\ub85c \uc2e4\ud589\ub418\uc5c8\uc74c\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<p>\uc791\uc5c5\uc774 \uc644\ub8cc\ub418\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 \ubabd\uace0 \uc178\uc744 \uc885\ub8cc\ud569\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762665536\" class=\"wp-block-code\"><code>quit()<\/code><\/pre>\n\n\n\n<p>\ubcc0\uacbd \ub0b4\uc6a9\uc744 \ud14c\uc2a4\ud2b8\ud558\ub824\uba74 \uc774\uc804\uc5d0 \uc791\uc131\ud55c \uad00\ub9ac\uc790\ub97c \uc0ac\uc6a9\ud558\uc5ec&nbsp;MongoDB&nbsp;\uc178\uc5d0 \uc561\uc138\uc2a4\ud569\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762674054\" class=\"wp-block-code\"><code>mongo -u myMongoAdmin -p --authenticationDatabase admin<\/code><\/pre>\n\n\n\n<p>\uc815\ud655\ud55c \ube44\ubc00\ubc88\ud638\ub97c \uc785\ub825\ud558\uba74&nbsp;MogoDB&nbsp;\uc258\ub85c \uc5f0\uacb0\ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<p>&#8220;admin&#8221;&nbsp;\ub370\uc774\ud130\ubca0\uc774\uc2a4\ub85c \uc804\ud658\ud558\uace0&nbsp;show users\ub97c \uc2e4\ud589\ud558\uc5ec \ubaa8\ub4e0 \uc0ac\uc6a9\uc790\uc640 \uc5ed\ud560\uc5d0 \ub300\ud55c \uc815\ubcf4\ub97c \uac00\uc838\uc635\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762688300\" class=\"wp-block-code\"><code>use admin\n\n# switched to db admin<\/code><\/pre>\n\n\n\n<p>\uc608\uc81c\uc5d0\uc11c \uc0ac\uc6a9\uc790\ub294 \ud55c \uba85\ubfd0\uc785\ub2c8\ub2e4:<\/p>\n\n\n\n<pre id=\"code_1705762724696\" class=\"wp-block-code\"><code>show users\n\n# In our example, we have only one user:\n# \n# &#91;\n#   {\n#     _id: 'admin.myMongoAdmin',\n#     userId: <strong>new<\/strong> UUID(\"a00ab5ca-5c1f-4a3b-8f67-be8a79c7649c\"),\n#     user: 'myMongoAdmin',\n#     db: 'admin',\n#     roles: &#91;\n#       { role: 'userAdminAnyDatabase', db: 'admin' },\n#       { role: 'readWriteAnyDatabase', db: 'admin' }\n#     ],\n#     mechanisms: &#91; 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]\n#   }\n# ]<\/code><\/pre>\n\n\n\n<p>Ubuntu 20.04\u00a0\ubc0f\u00a022.04\uc5d0\uc11c\u00a0MongoDB\ub97c \uc124\uce58 \ubc0f \uad6c\uc131\ud558\ub294 \ubc29\ubc95\uc744 \uc548\ub0b4\ud574 \ub4dc\ub838\uc2b5\ub2c8\ub2e4.\u00a0\uc774 \ud56d\ubaa9\uc5d0 \ub300\ud55c \uc790\uc138\ud55c \ub0b4\uc6a9\uc740\u00a0MongoDB Manual\uc744\u00a0\ucc38\uc870\ud558\uc2ed\uc2dc\uc624.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB&nbsp;\uad6c\uc131 MongoDB&nbsp;\uad6c\uc131 \ud30c\uc77c\uc740&nbsp;\/etc&nbsp;\ub514\ub809\ud1a0\ub9ac\uc5d0 \uc788\uc73c\uba70&nbsp;mongod.conf\ub77c\ub294 \uc774\ub984\uc744 \uac00\uc9c0\uace0 \uc788\uc2b5\ub2c8\ub2e4.&nbsp;\ud30c\uc77c\uc740&nbsp;YAML&nbsp;\ud615\uc2dd\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uae30\ubcf8 \uad6c\uc131 \uc124\uc815\uc740 \ub300\ubd80\ubd84\uc758 \uacbd\uc6b0\uc5d0 \ucda9\ubd84\ud569\ub2c8\ub2e4.&nbsp;\uadf8\ub7ec\ub098 \uc6b4\uc601 \ud658\uacbd\uc758 \uacbd\uc6b0 \ub2e4\uc74c\uacfc \uac19\uc774 \ubcf4\uc548 \uc139\uc158\uc758 \ubcf4\uc644\uc744 \ud574\uc81c\ud558\uace0 \uc561\uc138\uc2a4 \uc81c\uc5b4\ub97c \uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4: \uad8c\ud55c \ubd80\uc5ec \uc635\uc158\uc740 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ub9ac\uc18c\uc2a4 \ubc0f \uc791\uc5c5\uc5d0 \ub300\ud55c \uc0ac\uc6a9\uc790\uc758 \uc561\uc138\uc2a4\ub97c \uaddc\uc81c\ud558\ub294 \uc5ed\ud560 \uae30\ubc18 \uc561\uc138\uc2a4 \uc81c\uc5b4(RBAC)\ub97c \ud65c\uc131\ud654\ud569\ub2c8\ub2e4.&nbsp;\uc774 \uc635\uc158\uc744 \ud65c\uc131\ud654\ud558\uc9c0 \uc54a\uc73c\uba74 \uac01 \uc0ac\uc6a9\uc790\ub294 \ubaa8\ub4e0 \ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \uc561\uc138\uc2a4\ud560 \uc218 \uc788\uc73c\uba70 \ubaa8\ub4e0 &hellip; <a href=\"https:\/\/absol.kr\/?p=1211\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;MongoDB \uad6c\uc131\uacfc \uc0ac\uc6a9\uc790 \ucd94\uac00&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1211","post","type-post","status-publish","format-standard","hentry","category-d-service"],"_links":{"self":[{"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/posts\/1211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/absol.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1211"}],"version-history":[{"count":1,"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/posts\/1211\/revisions"}],"predecessor-version":[{"id":1212,"href":"https:\/\/absol.kr\/index.php?rest_route=\/wp\/v2\/posts\/1211\/revisions\/1212"}],"wp:attachment":[{"href":"https:\/\/absol.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/absol.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/absol.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}