Mongodb 3:
use admin
db.createUser(
{
user: "username",
pwd: "password",
roles: [ "root" ]
}
)
MongoDB older:
db.createUser({ user: "mongoadmin" , pwd: "mongoadmin", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})<
/code>