germancin
3/16/2018 - 5:09 PM

create user in mongo for terminal

create user in mongo for terminal

// this is the database.
use reporting

// creates the user.
db.createUser(
  {
    user: "germancin",
    pwd: "secure123",
    roles: [{ role: "dbOwner", db: "<dbName>" }]
  }
);

// Examples.
db.createUser(
  {
    user: "reportsUser",
    pwd: "12345678",
    roles: [
       { role: "read", db: "reporting" },
       { role: "read", db: "products" },
       { role: "read", db: "sales" },
       { role: "readWrite", db: "accounts" },
       { role: "dbOwner", db: "accounts" }
    ]
  }
);