Install MongoDB on OS X (10.6 Snow Leopard)

Here are the steps:

  1. Download the pre-compiled binaries from:
    http://www.mongodb.org/display/DOCS/Downloads

  2. Create mongodb folder and unpack the files there
    sudo mkdir /usr/local/mongodb

  3. Create the configuration file
    sudo touch /usr/local/mongodb/mongod.conf
    and paste these lines in it:
    dbpath = /usr/local/mongodb
    logpath = /var/logs/mongodb/output.log
    bind_ip = 127.0.0.1
    # DEFAULTS
    # port = 27017
    # noauth = true

    More configurations options you can find here:
    http://www.mongodb.org/display/DOCS/Command+Line+Parameters

  4. Add “/usr/local/mongodb/bin” to your $PATH
    or
    only for Leopard versions create a file “/etc/paths.d/mongodb” where you paste this path.

  5. Make mongodb starts when system starts
    touch /Library/LaunchDaemons/org.mongodb.mongod.plist
    and paste these lines in it:<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>org.mongodb.mongod</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/mongodb/bin/mongod</string>
    <string>run</string>
    <string>--config</string>
    <string>/usr/local/mongodb/mongod.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/usr/local/mongodb</string>
    <key>StandardErrorPath</key>
    <string>/var/log/mongodb/output.log</string>
    <key>StandardOutPath</key>
    <string>/var/log/mongodb/output.log</string>
    </dict>
    </plist>

    and then
    sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist

  6. See if it works (type in a terminal):

    $> mongo
    => MongoDB shell version: 1.2.4
    url: test
    connecting to: test

That’s it.

2 thoughts on “Install MongoDB on OS X (10.6 Snow Leopard)

  1. Thanks! Great step by step tutorial.

    According to the property list file, there is one little error in your mongod.conf file.

    The logpath value should be ‘/var/logs/mongodb/output.log’ instead of ‘/var/logs/mongodb’.

Leave a comment