Mongodb

Install Mongodb

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

sudo vi /etc/mongo.conf

systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0 #127.0.0.1

# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

security:
  authorization: enabled

Create adminuser:

mongo
use admin
db.createUser(
  {
    user: "mongoadmin",
    pwd: "",
    roles: [
      { role: "userAdminAnyDatabase", db: "admin" },
      { role: "readWriteAnyDatabase", db: "admin" }
    ]
  }
)
  • Login as admin
mongo -u mongoadmin -p --authenticationDatabase=admin

Creating Users

use test
db.createUser(
  {
    user: "test",
    pwd:  "", 
    roles: [ { role: "readWrite", db: "test" }]
  }
)
  • Login as database use
mongo -u test -p --authenticationDatabase=test

Authentication Database

MongoImport

Indexes

Mongoengine

Mongo Replication using Docker

Mongo Replication using Docker