Click here to Skip to main content
12,815,616 members (40,829 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 31 Oct 2011

Setting up MongoDB on OSX

, 31 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to set up MongoDB on OSX.

Recently I successfully downloaded and installed MongoDB on my Mac. I am a Windows developer dwelling in the world of Linux programming, so I wanted to blog about my experience as it may be helpful to other fellow devs who are new to Linux as well.

Most of the steps below are refinement / explanation of

  • Step 1 - Download MongoDB server - From website download MongoDB server and untar the files in some folder (MongoDB_Server).
  • Step 2 - Create a folder /data/db in your root. MongoDB server uses this path to store the database(s).
  • Step 3- Download MongoDB client - From, download a compatible client (same version as the server) and untar the files in client folder (MongoDB_Client)
  • Step 4 - If you haven't done so far, you must download package manager on OSX called homebrew. A package manager on linux is an application that makes it dead simple to download other applications and install them on your system. To download homebrew open a shell window and type: curl -L | tar xz --strip 1 -C /usr/local
  • Step 5 - Download boost C++ library - Execute: brew install boost
  • Step 6 - Download scons (Makefile executor) - Execute: brew install scons
  • Step 7 - Download pcre++ (Perl regular expression lib) - Execute: brew install pcre++
  • Step 8 - Build client - Navigate to the client folder and simply type: scons
  • Step 9 - Start server - Open a new shell window and navigate to server folder's bin subfolder and type: mangod. This should start the server !
  • Step 10 - Test client - Navigate to client folder and execute: ./clientTest (this should run a simple client test)
  • Step 11 - Write your own test: In the client folder's client/example subfolder, create a test program with code from and name it test.cpp
  • Step 12 - Now navigate to root client folder and execute: g++ -o test client/examples/test.cpp -I mongo -L. -lmongoclient -lpthread -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt
  • Step 13: Last step should compile your code and output test binary. Simply execute this binary to verify client code ! Ensure that your server is running all this time...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ashish Kaila
Software Developer (Senior) MixModes Inc. | Research In Motion
Canada Canada
Ashish worked for Microsoft for a number of years in Microsoft Visual Studio (Architect edition) and Windows Live division as a developer. Before that he was a developer consultant mainly involved in distributed service development / architecture. His main interests are distributed software architecture, patterns and practices and mobile device development.

Currently Ashish serves as a Technical Lead at RIM leading next generation BlackBerry media experience and also runs his own company MixModes Inc. specializing in .NET / WPF / Silverlight technologies. You can visit MixModes at or follow it on Twitter @MixModes

In his free time he is an avid painter, hockey player and enjoys travelling. His blog is at:

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 31 Oct 2011
Article Copyright 2011 by Ashish Kaila
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid