Links: Homepage | Documentation | Downloads
Dependencies: None
Version: 2.6.5

MongoDB is a scalable, high-performance, open source, schema-free, document-oriented database. MongoDB was created by 10gen and they have been kind enough to provide pre-compiled binaries for various platforms including OS X.

Get the Code

Switch to /usr/local/src and download the pre-compiled binaries.

cd /usr/local/src
curl --remote-name


Unpack the binaries into /usr/local.

tar -zxvf mongodb-osx-x86_64-VERSION.tgz -C ..

Create a symbolic link to /usr/local/mongodb.

ln -s mongodb-osx-x86_64-VERSION /usr/local/mongodb


Create a folder that will contain your databases. My databases are located in /usr/local/var/mongodb. You can place your databases wherever you'd like but make sure you update the path when mentioned throughout this article.

mkdir -p /usr/local/var/mongodb

Configuration File

Create a configuration file to customize your server.

nano /usr/local/mongodb/mongod.conf

Copy and paste the following text into the aforementioned file.

  path: /usr/local/var/log/mongodb.log
  destination: file
  logAppend: true
  dbPath: /usr/local/var/mongodb
  directoryPerDB: true
  smallFiles: true
    enabled: true
  fork: true
  port: 27017
    enabled: true
    RESTInterfaceEnabled: true


Execute the following lines to update your Bash startup script.

echo 'export PATH=/usr/local/mongodb/bin:$PATH' >> ~/.bash_profile

Load the new shell configurations.

source ~/.bash_profile

Manual Start/Stop

To start the MongoDB server.

mongod --config=/usr/local/mongodb/mongod.conf

To stop the MongoDB server.

killall mongod

Automatically Start the Server at Boot

Create a configuration file for Launchd.

nano ~/Library/LaunchAgents/org.mongodb.mongod.plist

Copy and paste the following text into the aforementioned file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">



Register with Launchd and start the server.

launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Deregister with Launchd.

launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist

Verify the Installation

To verify that you have correctly installed and started your MongoDB server, point your web browser to http://localhost:28017/ to load the MongoDB console.