웹개발
E QUERY [js] uncaught exception: Error: couldn't add user: not authorized on admin to execute command
jjnll
2022. 10. 4. 11:23
유저 생성이 안되는 상황
루트계정이어도 안되는건 마찬가지인데 이건 securitty.authorization이 true로 되어있어서 생기는 문제
1. security 주석처리
// 경로
/etc/mongod.conf
// conf내용 수정(=주석처리)
#security:
# authorization: enabled
2. mongod 재시작
systemctl restart mongod
3. db 선택 및 유저 생성
use admin
db.createUser({ user: "adminUser", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, { role: "dbAdminAnyDatabase", db: "admin" }, { role: "readWriteAnyDatabase", db: "admin" } ] })
// 이 후 로그인
mongo -u 'adminUser' -p 'password' --authenticationDatabase admin
끝.
728x90