Set Up MongoDB on Windows in Five Minutes

Step 1: Download a ZIP file containing the appropriate version of MongoDB from MongoDB.org.

Step 2: Create the folder C:\MongoDB

Step 3: Extract the contents of the downloaded ZIP file to the new folder.

Step 4: Within the C:\MongoDB folder, create the folders C:\MongoDB\Data\DB.  This folder will hold the MongoDB databases.

Step 5: Open a command prompt and run C:\MongoDB\bin\mongod –dbpath C:\MongoDB\Data\DB.

You should see output that looks something like the following:

C:\mongodb\bin\mongod –dbpath c:\mongodb\data\db
Tue Nov 19 08:27:43.083 [initandlisten] MongoDB starting : pid=8608 port=27017 dbpath=c:\mongodb\data\db 64-bit host=s2ua3031x9m
Tue Nov 19 08:27:43.084 [initandlisten] db version v2.4.8
Tue Nov 19 08:27:43.084 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Tue Nov 19 08:27:43.085 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack=’Service Pack 1′) BOOST_LIB_VERSION=1_49
Tue Nov 19 08:27:43.085 [initandlisten] allocator: system
Tue Nov 19 08:27:43.085 [initandlisten] options: { dbpath: "c:\mongodb\data\db"}
Tue Nov 19 08:27:43.122 [initandlisten] journal dir=c:\mongodb\data\db\journal
Tue Nov 19 08:27:43.123 [initandlisten] recover : no journal files present, no recovery needed
Tue Nov 19 08:27:43.206 [FileAllocator] allocating new datafile c:\mongodb\data\db\local.ns, filling with zeroes…
Tue Nov 19 08:27:43.207 [FileAllocator] creating directory c:\mongodb\data\db\_tmp
Tue Nov 19 08:27:43.246 [FileAllocator] done allocating datafile c:\mongodb\data\db\local.ns, size: 16MB,  took 0.037 secs
Tue Nov 19 08:27:43.247 [FileAllocator] allocating new datafile c:\mongodb\data\db\local.0, filling with zeroes…
Tue Nov 19 08:27:43.373 [FileAllocator] done allocating datafile c:\mongodb\data\db\local.0, size: 64MB,  took 0.125 secs
Tue Nov 19 08:27:43.374 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37 167ms
Tue Nov 19 08:27:43.375 [initandlisten] waiting for connections on port 27017
Tue Nov 19 08:27:43.375 [websvr] admin web console waiting for connections on port 28017

That’s it.  MongoDB is now running.

To verify that you can connect to the new MongoDB server, open a second command window and execute c:\mongodb\bin\mongo.

The Mongo shell will start.  You should see something like this:

C:\mongodb\bin\mongo
MongoDB shell version: 2.4.8
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
>

More information is available in the MongoDB online tutorials, including how to set up MongoDB as a Windows service.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: