Skip to content

Instantly share code, notes, and snippets.

@mislav
Created December 29, 2009 12:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save mislav/265272 to your computer and use it in GitHub Desktop.
Save mislav/265272 to your computer and use it in GitHub Desktop.
Install MongoDB using Homebrew and set it up for your user on OS X

This gist is outdated

Homebrew people have since included this in a recipe.

$ brew update
$ brew install mongodb
( follow the instructions given )
#!/bin/bash
# run with: curl -s http://gist.github.com/265272.txt | bash
set -e
localdir=$HOME/.mongodb
datadir=$localdir/data
conf=$localdir/mongod.conf
agentdir=$HOME/Library/LaunchAgents
agent=$agentdir/org.mongodb.mongod.plist
brew install mongodb
mongod=$(which mongod)
mkdir -p $datadir
mkdir -p $agentdir
# daemon configuration
echo "dbpath = $datadir
# Only accept local connections
bind_ip = 127.0.0.1" > $conf
# write launchd agent
echo "<?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>$mongod</string>
<string>run</string>
<string>--config</string>
<string>$conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>$localdir</string>
<key>StandardErrorPath</key>
<string>$localdir/error.log</string>
<key>StandardOutPath</key>
<string>$localdir/mongo.log</string>
</dict>
</plist>" > $agent
launchctl load $agent
echo "MongoDB should now be running - check its status at http://localhost:28017/"
@kristianmandrup
Copy link

How do I upgrade the mongo db recipe to install the latest 1.4.4 or 1.5.3 instead of the old 1.2.2?

@kristianmandrup
Copy link

Ah, $ brew edit mongodb. But what do I do from here?
So I see that I have a local clone of the homebrew project with a Library listing all the Formulas. But wow do I update brew to use the latest homebrew recipes? I don't see any mention of that on the wiki or anywhere else...
The whole homebrew documentation is all rather cryptic to me ;P
Thanks!

Kristian

@kristianmandrup
Copy link

Found the solution here:
http://biven.org/writing/post/homebrew_packages_for_mac_os/

After creating my own fork of homebrew on github

$ cd /usr/local
$ git remote add km git://github.com/kristianmandrup/homebrew.git
$ git pull km master

@mislav
Copy link
Author

mislav commented Jul 2, 2010

Hey. This gist is outdated. Homebrew recipe since has this built-in (read the notes it prints after install).

Update homebrew with:

$ brew update

You didn't need to fork it; I think it has latest stable mongo already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment