Database Reference
In-Depth Information
A.1.3
MongoDB on Windows
There two ways to install MongoDB on Windows. The easier, preferred way is to down-
load the precompiled binaries directly from the mongodb.org website. You can also
compile from source, but this is recommended only for developers and advanced
users. You can read about compiling from source in the next section.
P RECOMPILED BINARIES
First navigate to http://www.mongodb.org/downloads . There you'll see a grid with all
the latest downloadable MongoDB binaries. Select the download URL for the latest
stable version for your architecture. Here we'll install MongoDB v2.0 compiled for 64-
bit Windows.
Download the appropriate distribution, and then unzip it. You can do this from
the Windows Explorer by locating the MongoDB .zip file, right-clicking on it, and
then selecting Extract All... You'll then be able to choose the folder where the con-
tents will be unzipped.
Alternatively, you can use the command line. First navigate to your Downloads
directory. Then use the unzip utility to extract the archive:
C:\> cd \Users\kyle\Downloads
C:\> unzip mongodb-win32-x86_64-2.0.0.zip
To ru n M o n g o D B, y o u ' l l n e e d a d a t a f o ld e r. By d e f a u lt , t h e mongod daemon will store
its data files in C:\data\db . Open the Windows command prompt, and create the
folder like so:
C:\> mkdir \data
C:\> mkdir \data\db
You're now ready to start the server. Just change to the MongoDB bin directory and
launch the mongod executable:
C:\> cd \Users\kyle\Downloads
C:\Users\kyle\Downloads> cd mongodb-win32-x86_64-2.0.0\bin
C:\Users\kyle\Downloads\mongodb-win32-x86_64-2.0.0\bin> mongod.exe
If all goes well, you should see something like the following abridged startup log. Note
the last lines, confirming that the server is listening on the default port of 27017:
Thu Mar 10 11:28:51 [initandlisten] MongoDB starting :
pid=1773 port=27017 dbpath=/data/db/ 64-bit
Thu Mar 10 11:28:51 [initandlisten] db version v2.0.0, pdfile version 4.5
...
Thu Mar 10 11:28:51 [initandlisten] waiting for connections on port 27017
Thu Mar 10 11:28:51 [websvr] web admin interface listening on port 28017
If the server terminates unexpectedly, then refer to section A.5.
Finally, you'll want to start the MongoDB shell. To do that, open a second terminal
window, and then launch mongo.exe :
C:\> cd \Users\kyle\Downloads\mongodb-win32-x86_64-2.0.0\bin
C:\Users\kyle\Downloads\mongodb-win32-x86_64-2.0.0\bin> mongo.exe
Search WWH ::




Custom Search