This guide is geared towards web developers using wamp. As you know, wamp keeps your filesystem tidy by installing apache, mysql, and php all inside c:\wamp. My setup is a Windows 7 64bit machine running wamp 32bit (Why run wamp 32bit on Windows 7 64bit?). Although untested on each, this guide should also work for Windows XP, Vista, and Windows Server variants.

MongoDB is a open source, high performance,NOSQL database server(mongod.exe) and shell(mongo.exe) developed by 10gen. MongoDB win32 binaries are available in both 64bit and 32bit flavors. The win32 binaries are packaged as a very simple zip file containing only the binary executables, no installer, and no example config files.

Lets get started! We will install mongodb into the c:\wamp directory, create conf,data,log directories, and configure mongod to run as a windows service.

1. Download the latest win32 build of mongodb, choosing your architecture (32bit or 64bit) from

2. Create the directory c:\wamp\bin\mongodb\ and extract the contents of the zip archive here. Your directory structure should look something like the following depending on the version number and architecture you download.

3. Create the following directories

mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\data\db
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs
mkdir c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf

4. Create the file c:\wamp\bin\mongodb\mongodb-win32…2.x.x\conf\mongodb.conf and add the following base configuration.

# mongodb.conf

# data lives here

# where to log

# only run on localhost for development
bind_ip =                                                             

port = 27017
rest = true

5. Execute the windows console(command line) as administrator and change to the c:\wamp\bin\mongodb\mongodb-win32…2.x.x\bin directory.

6. Execute the following command to install mongod as a windows service.

mongod.exe --install --config c:\wamp\bin\mongodb\mongodb-win32...2.x.x\conf\mongodb.conf --logpath c:\wamp\bin\mongodb\mongodb-win32...2.x.x\logs\mongodb.log

7. Execute services.msc and scroll down to find the Mongo DB service. Right click on the service and choose start. From here you can choose the have the service started automatically on boot or change it to manual and you will need to start the service each time.

8. We can confirm that mongod is running by inspecting the log file located at c:\wamp\mongodb\mongodb-win32…2.x.x\logs\mongodb.log

Note: Each time you make changes to mongodb.conf, you will need to restart the Mongo DB service.

Adding mongo.exe to your path

mongo.exe is the MongoDB shell, it will be very convenient to add the bin directory to your PATH environment variable so that you can simple type mongo at the command line regardless of your current working directory.

1. Right Click on My Computer
2. Choose Properties and Advanced System Settings
3. Click the Environment Variables button
4. Under system variables scroll down and double click on Path.
5. Append the following to the existing Variable value.


Note: The ; (semicolon) at the beginning is the delimiter between each path. While you are here, it’s a good idea to also add the path to php.exe.


Remember, your version numbers will probably vary slightly so double check the correct path for your machine and revision of wamp.

Use mongo.exe to confirm everything is up and running

Start | Run | cmd.exe 
c:\> mongo
MongoDB shell version: 2.0.2
connecting to: test
> use test;
switched to db test
> db.test.insert( {"hello":"world"} );
> db.test.find();
{ "_id" : ObjectId("4f33df871c81e6d645a53dd3"), "hello" : "world" }
> exit;

Installing the Mongo PHP Extensions (php_mongo.dll)

1. Download the latest version of the win32 php extension from For this example I used

2. Extract the zip archive find the mongo-1.2.5-php5.3vc9ts/ directory. The ts in the folder name means thread safe.

3. Copy c:\wamp\bin\php\php-5.3.x\ext\

4. Edit c:\wamp\bin\apache\Apache2.2.xx\bin\php.ini and add the following line near the other loaded extensions.


5. Restart all the wamp services by clicking on the wamp task tray icon and choosing ‘Restart All Services’.

6. Open your browser to to confirm that the mongo driver is loaded.

Additional Tips for running MongoDB on Windows

Stop and Start the mongod service from the command line

Note: You must be running the command prompt shell with administrative privileges for the following commands to work.

Stop mongod

c:\> NET STOP "Mongo DB"

Start mongod

c:\> NET START "Mongo DB"

Backup your mongodb data files

1. Stop the “Mongo DB” service.

2. Copy c:\wamp\bin\mongodb\mongodb-win32…2.x.x\data to your backup destination.

3. Restart the “Mongo DB” service.

Why run wamp 32bit on Windows 7 64bit?

The Mongo PHP driver does not have a 64bit win32 binary, if you are running the 64bit version of wamp, php will refuse to load the 32 bit version of php_mongo.dll. While wamp and the php driver are 32bit, it’s still recommended to install the 64bit version of mongodb server if you plan on working with collections over 2GB.



  • wamp mongodb
  • InstallingMongoDBonWindowstheWAMPway-PRONIQUESoftware
  • mongodb wamp
  • wampserver mongodb
  • wamp mongo
  • install mongodb wamp
  • installing phpdriver for mongodb for wamp on windows xp
  • my local mongo is saying connect failed system actively refused