Last active
January 24, 2021 13:00
-
-
Save ttrasn/cbb0d3f5e93a9e58f57029bf06ffd7ae to your computer and use it in GitHub Desktop.
secure mongodb database for access from remote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
access from remote : | |
go to mongodb config `/etc/mongod.conf`, in `net` part, set `bindIP` to trusted IPs. | |
then restart service | |
also open mongodb port & restart firewall | |
------------------------------------------------ | |
1. login to mongodb with `mongo`, | |
2. use admin | |
3. add user with password | |
db.createUser({ | |
user: "user", | |
pwd: "password", | |
roles: [ | |
{ role: "dbAdmin", db: "admin" }, | |
], | |
}); | |
4. go to mongodb config in `/etc/mongod.conf` change to this : | |
security: | |
authorization: "enabled" | |
then restart service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment