How to do authentication for MongoDB in Java

Here in this article we will see how to perform MongoDB authentication in Java. The MongDB Java Driver version used is 3.0.0. 1) First create the ServerAddress instance ServerAddress serverAddress = new ServerAddress(“localhost”, 27017); 2) Create MongoCredential instance by providing the username and password for your database MongoCredential mongoCredential = MongoCredential.createCredential(“user1”, “demodb”, “pwd1”.toCharArray()); where user1 […]

How to create user in MongoDB

Below are the steps by which a user can be created for a database in MongoDB 1) switch to your database on which the user needs to be created for granting access > use demodb 2) Create user on this database > db.createUser({user:’user1′, pwd: ‘pwd1′, roles:[{role:’readWrite’, db:’demodb’}]}) this will add a user for demodb in […]

Useful Commands in MongoDB

Useful Commands in MongoDB MongoDB is getting popular day by day due its simplicity and easy to use features. It is a leading NoSQL database and provides strong combination with Node.js. It is a document oriented NoSQL database. We will see the various useful commands of MongoDB 1) Show list of existing database show dbs […]

How to install MongoDB 3.0.3 on Mac OS

How to install MongoDB 3.0.3 on Mac OS MongoDB is one of the popular NoSQL database being used.  It is document oriented database.  The BSON objects are being stored in the database. The high documentation support and easy to learn are the key features for its popularity.  It provides great combination with Node.js. Let us […]