MongoDB install with Homebrew on Mac OS X

The command to install the server is quite simple :

sudo brew install mongodb

Since it's our first install and we want it to run automatically at every login, we have to enable the autolaunch :

cp /usr/local/Cellar/mongodb/1.8.0-x86-64/Library/LaunchDaemons/org.mongodb.mongod.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Now that we're done we the server side, let's install the php driver :

sudo brew install mongo-php

As I'm writing those lines, the current version is 1.1.4 so we have to enable the extension in our php.ini and restart our apache server as follow :

vim /usr/local/Cellar/php/5.3.6/etc/php.ini
extension="/usr/local/Cellar/mongo-php/1.1.4/mongo.so"
sudo apachectl restart

Then to browse easily your database, you can download and run MongoHub. To connect to your local database, the default settings are the following :

  • Host : localhost
  • Port : 27017

By default, there is no username nor password since MongoDB advice to use entrusted environments