Thursday, 24 December 2015

Setting up MongoDB

Installation Procedure:


  • If your system is running on one of these Windows Server 2008 R2, Windows Vista, or windows 7 Please follow the below
  • To resolve memory mapping issues while installing MongoDB one has to install a hotfix from https://support.microsoft.com/en-gb/kb/2731284 which has a link to download hotfix sent through an email .


  • There are 3 builds of MongoDB for Windows
    • MongoDB for Windows 64 bit
    • MongoDB for Windows 32 bit
    • MongoDB for Windows 64 bit legacy
Download the latest release compatible with your system from the link: http://www.mongodb.org/downloads?_ga=1.149793334.1228321965.1432748496





  • Once the download is complete,double click on the installer package and follow the installation wizard. While installing you must specify a installation directory by choosing “Custom” option, The installation wizard will assume that you have installed at C:\mongodBy following the above procedure the following 10+ executable files will installed in the bin folder. And they are required files to MongoDB mongod.exe, mongo.exe, mongodump.exe, mongorestore.exe, mongoimport.exe, mongoexport.exe, mongostat.exe, and mongotop.exe.




  • MongoDB need a folder (data directory) to store its data. By default, it will store in “C:\data\db“, create this folder manually. MongoDB won’t create it for you. 
  • It’s recommended to add C:/MongoDB/Server/3.0/bin to Windows environment variable, so that you can access the MongoDB’s commands in command prompt easily as shown





Setting up Eclipse for MongoDB:

  • To connect to mongodb from java, we need to install mongodb java driver.
  • Get jar file of mongodb Java driver from: http://docs.mongodb.org/ecosystem/drivers/java/
  •  Let’s see with an example how to work with mongodb java.
  •  In eclipse: create dynamic web project. Right click project->configure build path->Add external Jars. Select and add mongo db java jar to build path.




  • Add jar file to class path also:  Run->Run configuration-> select your server-> class path. Add jar files.



This completes setting up mongo db. Now you can start writing code to connect to mongo db and perform operation on mongodb. 






No comments:

Post a Comment