This tutorial has sections covering the following topics:
- Windows: Instructions coming soon. Try following the instructions provided by MongoDB.
- Linux: We assume you can figure this out yourself. See MongoDB site.
If you have any trouble installing MongoDB, please post to Piazza.
MacOS: Installing MongoDb
We will be mostly following the instructions from the MongoDB website
1) Install Homebrew
Homebrew is a package manager for MacOS that allows you to install command-line tools for Mac, similar to npm for NodeJS.
First install Homebrew if you don’t have it already.
Run the following in a terminal:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2) Install MongoDB
Now install MongoDB via Homebrew.
Run the following in a terminal:
brew install mongodb
3) Create /data/db
The databases you create on your local machine via MongoDB will be stored by default in a directory called /data/db
. You will need to create this directory. Since it is a directory on root, you will need superuser permissions to create this directory.
Run the following command in a terminal (don’t forget the first slash):
$ sudo mkdir -p /data/db/
4) Fix the permissions for /data/db
Run the following command in a terminal (don’t forget the first slash):
$ sudo chown -R $USER /data/db
5) Try running mongod
and accept incoming connections.
Now try running mongod
:
$ mongod
This should start up the MongoDB server process until you kill it via Command-C.
If you get prompted on whether to accept incoming connections, you should.