Installing MongoDB

For the purposes of development, it is recommended to run a MongoDB server on your local machine. This will permit you to iterate quickly and try new things without fear of destroying a production database. Additionally, you will be able to develop with MongoDB even without an Internet connection.

Depending on your operating system, you may have multiple options for how to install MongoDB locally.

Most modern UNIX-like systems will have a version of MongoDB available in their package management system. This includes FreeBSD, Debian, Ubuntu, Fedora, CentOS and ArchLinux. Installing one of these packages is likely the most convenient approach, although the version of MongoDB provided by your packaging vendor may lag behind the latest release from 10gen. For local development, as long as you have the latest major release, you are probably fine.

10gen also provides their own MongoDB packages for many systems which they update very quickly on each release. These can be a little more work to get installed but ensure you are running the latest-and-greatest. After the initial setup, they are typically trivial to keep up-to-date. For a production deployment, where you likely want to be able to update to the most recent stable MongoDB version with a minimum of hassle, this option probably makes the most sense.

In addition to the system package versions of MongoDB, 10gen provide binary zip and tar archives. These are independent of your system package manager and are provided in both 32-bit and 64-bit flavours for OS X, Windows, Linux and Solaris. 10gen also provide statically-built binary distributions of this kind for Linux, which may be your best option if you are stuck on an older, legacy Linux system lacking the modern libc and other library versions. Also, if you are on OS X, Windows or Solaris, these are probably your best bet.

Finally, you can always build your own binaries from the source code. Unless you need to make modifications to MongoDB internals yourself, this method is best avoided due to the time and complexity involved.

In the interests of simplicity, we will provide the commands required to install a stable version of MongoDB using the system package manager of the most common UNIX-like operating systems. This is the easiest method, assuming you are on one of these platforms. For Mac OS X and Windows, we provide instructions to install the binary packages from 10gen.

Ubuntu / Debian:

sudo apt-get update; sudo apt-get install mongodb

Fedora:

sudo yum install mongo-stable-server

FreeBSD:

sudo pkg_add -r mongodb

Windows:

Go to http://www.mongodb.org and download the latest production release zip file for Windows—choosing 32-bit or 64-bit depending on your system. Extract the contents of the zipfile to a location like C:\mongodb and add the bin directory to your PATH.

Mac OS X:

Go to http://www.mongodb.org and download the latest production release compressed tar file for OS X—choosing 32-bit or 64-bit depending on your system. Extract the contents to a location like /usr/local/ or /opt and add the bin directory to your $PATH. For exmaple:

cd /tmp
wget http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-1.8.3-rc1.tgz
tar xfz mongodb-osx-x86_64-1.8.3-rc1.tgz
sudo mkdir /usr/local/mongodb
sudo cp -r mongodb-osx-x86_64-1.8.3-rc1/bin /usr/local/mongodb/
export PATH=$PATH:/usr/local/mongodb/bin

Get MongoDB and Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.