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
To be able to create a new user, you need to first disable security in /etc/mongod.conf
// security:
// authorization: enabled
Then restart Mongodb server
sudo service mongo restart
After this you can add the user and role that you want from the shell.
db.createUser({
user: 'test_user',
pwd: 'test',
roles: [
{ role: "userAdmin", db: "test" },
{ role: "dbAdmin", db: "test" },
{ role: "readWrite", db: "test" }
]
})
To enable authenticated connection Uncomment the line again in /etc/mongod.conf
security:
authorization: enabled
and restart the server again