← 전체로 돌아가기
스킬 database

몽고쉘 연결 & 인증

몽고쉘 Atlas/로컬 연결, admin 계정 인증 방법 정리.

mongodbmongoshatlasauthenticationshell

몽고쉘 연결

Atlas 클러스터 연결은 아래처럼.

mongosh "mongodb+srv://cluster0.eonroyn.mongodb.net/[DB이름]" --apiVersion 1 --username [유저이름] --password [비밀번호]
  • [DB이름]: myFirstDatabase 대신 실제 디비 이름으로 바꿔 넣기.
  • [비밀번호]: --password 뒤에 실제 암호 바로 입력하면 됨.

로컬 몽고쉘은 그냥 mongosh 치면 접속.

admin 계정 로그인

use admin
db.auth("[아이디]","[비밀번호]")

[아이디][비밀번호]는 실제 계정 정보로.

여기서 배울 것

  1. Atlas 몽고쉘 연결 URI 구조 파악.
  2. --password 플래그로 암호 바로 입력 가능.
  3. 로컬 몽고쉘 접속은 `mongosh`로 퉁침.
  4. admin 계정 인증은 `use admin` 후 `db.auth`로.
원본 파일 보기 (.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”)`