Installing MongoDB on Mac OS X
If you are looking for a straightforward, no-headache way to install Mongodb on Mac OS X you have come to the right place. If you are looking for a customized, tricky installation from source, you need to look somewhere else.
There are many ways to install MongoDB on MacOS X: from source, binary download, MacPorts, and Homebrew to name what I am aware about. Go the Homebrew way, and ditch the rest. In fact, use Homebrew for managing all your packages on Mac OS X. This all you need to do to get MongoDB running on your system:
$ brew update
$ brew install mongodb
$ mkdir -p /data/db
If you don't create that directory you will get an error "exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating", when you try to start the MongoDB server.
Note to Mac OS X Lion users, if
mkdir -p /data/db fails. Do this:
$ sudo mkdir -p /data/db
$ sudo chown `id -u` /data/db
What the above commands did is create the required directory and change ownership to you, so that you can run
mongod without any permission errors.
If everything goes fine, you have successfully installed MongoDB on your system. To start the server, open a terminal and type:
MongoDB starting : pid=4932 port=27017 dbpath=/data/db/ 64-bit
To connect to the sever and playing with the data, open a terminal and type:
MongoDB shell version: 1.8.3
There you go! No head-ache, no dependency problems, nothing to worry about - just get the thing installed and running.