Wednesday 15 July 2015

MongoDB Server Instance Using cmd prompt

In my previous blog you might have seen a simple way of starting mongo db server. But that is good when you are starting your server with default options like port :27017. but you are looking for customization then you should get used of cmd prompt for now. Lets go step by step.



Step 1: So let’s run command prompt in machine. In case you are finding it difficult to open cmd. Press win key and r from your keyboard.  


{(Win key + R) and type cmd, then press enter}



 


Your cmd prompt appears on the screen.



 


 

Step 2: Next step would be to change the directory, as right now command is running from user’s directory. So we will move to the mongo DB bin directory where mongo.exe is available.


To do so we can type command


{cd “C:\Program Files\MongoDB\Server\3.0\bin”} where cd àchange directory.

 

 Now our command has moved to bin directory of MongoDB where all packages are available.

 

Step 3: Before we start the instance, the most important thing is we should create a DB path where the database /collections of the server will be stored. If you are not going to provide data path separately then server will throw an error, because by default this looks for the database directory (C:\data\db). So in order to create this directory, please type command


{md “C:\data\db”} in your command prompt.



 


 

Step 4: Next we can start server, as explained above we can run mongod.exe to start the server. As first we are gonna run this instance without any authentication, we can use default configuration of MongoDB like the port would be 27017, ip will be localhost etc. for that we don’t need to provide any info. Here is the command


{mongod and press enter}


And your server is ready and listening at localhost:27017.



 


 

 References:

http://docs.mongodb.org/v2.2/reference/mongod/

No comments:

Post a Comment