Mongosh 설치 LINK
$ mongo mongodb://localhost:27017/admin?authSource=admin --username jamie
Enter password:
> show users;
{
"_id" : "admin.jamie",
"userId" : UUID("da759198-7169-4dff-b04c-cb9168fa6055"),
"user" : "jamie",
"db" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
$ mongosh mongodb://localhost:27017/admin?authSource=admin --username jamie
Enter password: ***********
> show users
[
{
_id: 'admin.jamie',
userId: UUID("da759198-7169-4dff-b04c-cb9168fa6055"),
user: 'jamie',
db: 'admin',
roles: [ { role: 'root', db: 'admin' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
]
mongodb://localhost:27017/admin?authSource=admin --username jamie
mongodb://
: mongodb에 연결localhost:27017/
: mongodb 서비스 주소와 포트admin
: 접속할 Database?authSource=admin
: 인증 정보 Database = admin--username jamie
: 사용자명 jamie# 규칙
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
# 적용 예
mongodb://jamie:jamie1234%21%21@localhost:27017/?authSource=admin
MongoDB 공식 가이드 - https://docs.mongodb.com/guides/server/drivers/
MongoDB 공식 메뉴얼(연결 문자열 URI 형식) - https://docs.mongodb.com/manual/reference/connection-string/