The Go Blog

mongodb

bantana
5 February 2017

tags: mongodb

createdb

use test

create collection

db.test.insert({"company": "manqian corp."})

> db.test.find()
{ "_id" : ObjectId("5897366444ee56e1ecfa7f7a"), "company" : "manqian corp." }

security

createUser

use test
db.createUser(
 {
   user: "accountUser",
   pwd: "password",
   roles: [ "readWrite", "dbAdmin" ]
 }
)

start mongodb with auth

/usr/bin/mongod --auth -f /etc/mongod.conf