example-mongodb:PRIMARY> db
admin
example-mongodb:PRIMARY> db.createUser({user:"tom",pwd:"admin123.com",roles:[{"role":"root","db":"admin"}]})
Successfully added user: {
"user" : "tom",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
example-mongodb:PRIMARY> show users
{
"_id" : "admin.mms-automation",
"userId" : UUID("34c08f3a-63a3-42a2-be32-bba19e2da095"),
"user" : "mms-automation",
"db" : "admin",
"roles" : [
{
"role" : "backup",
"db" : "admin"
},
{
"role" : "clusterAdmin",
"db" : "admin"
},
{
"role" : "dbAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "readWriteAnyDatabase",
"db" : "admin"
},
{
"role" : "restore",
"db" : "admin"
},
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-256"
]
}
{
"_id" : "admin.my-user",
"user" : "my-user",
"db" : "admin",
"roles" : [
{
"role" : "clusterAdmin",
"db" : "admin"
},
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
],
"userId" : UUID("52ba65a4-6a96-42dd-b200-81f507a728b7"),
"mechanisms" : [
"SCRAM-SHA-256"
]
}
example-mongodb:PRIMARY>