Installing MongoDB on Mac OX X Lion

Today I tried to install mongodb via MacPorts on Mac OS X Lion. I got this error message:

Error: Target returned: shell command failed (see log for details)
Log for mongodb is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_mongodb/mongodb/main.log
Error: Status 1 encountered during processing.
To report a bug, see <>

Maybe it is not the best idea to install MongoDB via MacPorts. I just downloaded the compiled binarys from the MongoDB Homepage: Just unzip it and that’s it.

No you have to create a directory.

mkdir /data
cd /data
mkdir db

MongoDB expects that this directory exists and puts all necessary DB files into this directory.

Navigate in the command line to the unpacked directory and execute this command as root to start the MongoDB server:


And the server is running 🙂
In another shell you can start the client. The client can run without root rights.


Now you can start to work

> { a : 1 } )

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

8 thoughts on “Installing MongoDB on Mac OX X Lion

  1. Here is a work around to get mongodb to install in MacPorts:

    sudo port install mongodb configure.cpp=/usr/bin/cpp configure.cxx=/usr/bin/g++

  2. That is up to you. By default it is running under root. And nobody else should write or execute it. But you can also create a mongo user and execute the mongo service as mongo user.
    Self downloaded and installed software is usually under /opt. For example /opt/mongo.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: