프로그래밍/DB
[DB] mongoDB 외부 접속 허용하기
Karsei
2017. 1. 15. 21:24
설정에서 bindIp 부분을 건드려주면 된다.
1. 우선 설정 파일로 들어간다.
$ vi /etc/mongod.conf
2. bindIp 부분을 건드려준다.
기본적으로 아래와 같이 되어 있다.
bindIp: 127.0.0.1
이것을 주석 처리해주거나 0.0.0.0을 써준다.
#bindIp: 127.0.0.1
또는
bindIp: 0.0.0.0
만약, 여러 개의 IP를 지정하면서 원하는 IP만 접속이 가능하게 하려면 대괄호를 써서 이용해야 한다.
bindIp: [127.0.0.1, 123.234.213.123]
아래는 전체 예시
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 65000
bindIp: [127.0.0.1, 123.234.213.123]
#bindIp: 0.0.0.0
#processManagement:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp: