Setting up and running MongoDB on OS X

SneWs's picture

My latest fascination is MongoDB, a document oriented database that stores data in the JSON format. It's a fast and simple to use database. And it's even easier to set up. This short post documents the basic setup and configuration needed to use MongoDB on OS X.
The first thing to do is to install Homebrew if you're one of the two people still not using Homebrew as you're package manager on OS X ^^. You install Homebrew by navigating to this page. The guide tells you issue the following command in Terminal (and install Xcode if you haven't):

ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"

When Homebrew is installed, it's time to install MongoDB using Homebrew.
In Terminal:

brew install mongodb

Now, MongoDB is installed at

/usr/local/Cellar/mongodb/[version-ARCH]

To start MongoDB, issue the following command in Terminal (in my case it's installed to 1.8.1-x86_64, adjust this to you're actual location):

mongod run --config /usr/local/Cellar/mongodb/1.8.1-x86_64/mongod.conf

MongoDB should now be up and running, to verify, in Terminal:

mongo

And you should see something like this:

MongoDB shell version: 1.8.1
connecting to: test

To list all databases, enter the following command:

show dbs

That's it! You're now up and running MongoDB on you OS X machine.
To learn more:

Happy coding!

Post new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
© 2008 - 2012 Marcus Grenängen. Drupal theme by Kiwi Themes.