I am using mongoDB Cluster with version 3.4 in google cloud compute engine, actually past week my database got attacked by hackers that\'s why i thought about using authorizatio
Once you are connected to this first node, you can initiate the replica set with rs.initiate(). Again, this command must be run from the same host as the mongod to use the localhost exception.
We can create our admin user with the following commands:
rs.initiate()
use admin
db.createUser({
user: "admin",
pwd: "pass",
roles: [
{role: "root", db: "admin"}
]
})