DB/mongoDB

[MongoDB] not authorized on mydb to execute command 에러 해결

MOMOBOB 2024. 5. 2. 06:50
반응형

Error

MongoDB를 연결하면 아래 메시지가 뜨면서 연결이 되지 않음

 

MongoDB shell version: 2.6.1
connecting to: localhost:27017/admin
Welcome to the MongoDB shell!
The current date/time is: Thu May 29 2014 17:47:16 GMT-0400 (EDT)
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }

 

반응형

 


 

Solution

관리자를 추가할 때 역할을 루트로 설정하면 정상동작함.

use admin
db.createUser(
  {
    user: 'admin',
    pwd: 'password',
    roles: [ { role: 'root', db: 'admin' } ]
  }
);
exit;

 

 


Thank you!

반응형