E QUERY [js] uncaught exception: Error: couldn't add user: not authorized on admin to execute command
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
'웹개발' 카테고리의 다른 글
mongodump & mongorestore (0) | 2022.10.12 |
---|---|
mongoDB 설치 in window (0) | 2022.10.12 |
74680 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=dumped, signal=ABRT) (1) | 2022.09.26 |
React 시작하기 + 포트 지정 (1) | 2022.09.14 |
Error: listen EADDRINUSE (LIN/WIN) (0) | 2022.09.13 |