Wednesday, 18 February 2015

Setting up MongoDB

Download mongoDB from https://www.mongodb.org/downloads. After installation, add mongoDB bin path to system path.

Step 1: Create a directory, where mongoDB stores data. For example I created directory “C:\data\db”.

Step 2: Run the command ‘mongod.exe --dbpath "c:\data\db"’. This command starts MongoDB server.

C:>mongod.exe --dbpath "c:\data\db"
2015-01-11T20:51:29.161+0530 [initandlisten] MongoDB starting : pid=5428 port=27017 dbpath=c:\data\db 64-bit host=RENT-MIS-LT3016
2015-01-11T20:51:29.161+0530 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2015-01-11T20:51:29.161+0530 [initandlisten] db version v2.6.6
2015-01-11T20:51:29.161+0530 [initandlisten] git version: 608e8bc319627693b04cc7da29ecc300a5f45a1f
2015-01-11T20:51:29.161+0530 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
2015-01-11T20:51:29.161+0530 [initandlisten] allocator: system
2015-01-11T20:51:29.161+0530 [initandlisten] options: { storage: { dbPath: "c:\data\db" } }
2015-01-11T20:51:29.221+0530 [initandlisten] journal dir=c:\data\db\journal
2015-01-11T20:51:29.221+0530 [initandlisten] recover : no journal files present, no recovery needed
2015-01-11T20:51:29.281+0530 [initandlisten] allocating new ns file c:\data\db\local.ns, filling with zeroes...
2015-01-11T20:51:30.601+0530 [FileAllocator] allocating new datafile c:\data\db\local.0, filling with zeroes...
2015-01-11T20:51:30.601+0530 [FileAllocator] creating directory c:\data\db\_tmp
2015-01-11T20:51:30.831+0530 [FileAllocator] done allocating datafile c:\data\db\local.0, size: 64MB,  took 0.221 secs
2015-01-11T20:51:30.831+0530 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }
2015-01-11T20:51:30.831+0530 [initandlisten]     added index to empty collection
2015-01-11T20:51:30.831+0530 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0  reslen:37 1556ms
2015-01-11T20:51:30.851+0530 [initandlisten] waiting for connections on port 27017

Step 3: Open other command prompt, and run ‘mongo.exe’
C:\>mongo.exe
MongoDB shell version: 2.6.6
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
>

To get list of commands use “db.help()”.




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment