← 전체로 돌아가기
스킬 database

MongoDB 쉘 연결 및 인증

MongoDB 쉘 연결 및 관리자 인증 방법

mongodbmongoshdatabase-connectionauthenticationshell

MongoDB 쉘 연결 및 관리자 인증 팁이야.

  • MongoDB Atlas 연결: bash mongosh "mongodb+srv://<클러스터주소>/<DB이름>" --apiVersion 1 --username <유저명> --password <비밀번호> <DB이름>은 실제 DB명으로, <비밀번호>--password 뒤에 입력하면 돼.

  • 로컬 mongosh 실행: bash mongosh 설치되어 있다면 터미널에서 바로 실행 가능.

  • 관리자 계정 인증: javascript use admin db.auth("admin_id", "admin_pwd") admin DB로 이동 후 db.auth()로 인증하면 됨.

여기서 배울 것

  1. MongoDB Atlas 클러스터에 mongosh로 연결하는 방법
  2. `--password` 옵션을 이용한 비밀번호 입력
  3. `mongosh` 기본 실행 방법
  4. `admin` 계정으로 인증하는 절차
원본 파일 보기 (.claude/skills/tn-mongo-shell-connection/SKILL.md)
---
name: MongoDB Shell 연결 및 인증
description: This skill should be used when the user asks to connect to a MongoDB shell, including MongoDB Atlas clusters, or needs to authenticate an admin account within the `mongosh` environment.
version: 1.0.0
source: /home/son/prj/resume/backup_notes_260317/notion/Tech Note/몽고쉘 연결 f4e0f9b0b2eb4b7d8d5b9056ae07b204.md
---

# 몽고쉘 연결

![Screen Shot 2023-05-03 at 11.30.12 AM.png](%EB%AA%BD%EA%B3%A0%EC%89%98%20%EC%97%B0%EA%B2%B0/Screen_Shot_2023-05-03_at_11.30.12_AM.png)

connect- mongo shell

![Screen Shot 2023-05-03 at 11.30.30 AM.png](%EB%AA%BD%EA%B3%A0%EC%89%98%20%EC%97%B0%EA%B2%B0/Screen_Shot_2023-05-03_at_11.30.30_AM.png)

mongosh "mongodb+srv://cluster0.eonroyn.mongodb.net/myFirstDatabase" --apiVersion 1 --username urustin

myfirstdatabase를 디비 이름으롭 바꾸고

뒤에 —password 쳐서 실제 암호로 입력

mongosh "mongodb+srv://cluster0.eonroyn.mongodb.net/db_menu" --apiVersion 1 --username urustin --password asdf1234

AWS Installed

![Screen Shot 2023-12-29 at 3.24.11 PM.png](%EB%AA%BD%EA%B3%A0%EC%89%98%20%EC%97%B0%EA%B2%B0/Screen_Shot_2023-12-29_at_3.24.11_PM.png)

just put “mongosh”

**login to admin account**

![Screen Shot 2023-12-29 at 3.26.37 PM.png](%EB%AA%BD%EA%B3%A0%EC%89%98%20%EC%97%B0%EA%B2%B0/Screen_Shot_2023-12-29_at_3.26.37_PM.png)

`use admin`

`db.auth(”id”,”pwd”)`