Skip to content

Instantly share code, notes, and snippets.

@ttrasn
Last active January 24, 2021 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttrasn/cbb0d3f5e93a9e58f57029bf06ffd7ae to your computer and use it in GitHub Desktop.
Save ttrasn/cbb0d3f5e93a9e58f57029bf06ffd7ae to your computer and use it in GitHub Desktop.
secure mongodb database for access from remote
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