K
K
KnightForce2017-01-18 22:19:21
MongoDB
KnightForce, 2017-01-18 22:19:21

How to create a user for mongoDB?

How to create a user for mongoDB using Mongoose or Mongo native driver?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kalinin, 2017-01-26
@enhorse

createUser
for Java something like this

MongoClient mongo = new MongoClient("localhost", 27017);
MongoDatabase db =  mongo.getDatabase("testDb");
BasicDBObject command = new BasicDBObject();
command.put("createUser", "testUser");
command.put("pwd", "testPassword");
command.put("roles", new String[]{"readWrite"});
db.runCommand(command);

How to do something similar in Mongoose is written, for example, here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question