-
Check if homebrew is installed:
brew
- If not, install Homebrew by following the instructions on the web page
- If brew is already installed
brew upgrade
.
-
Install Mongodb on Mac OS X:
brew install mongodb
In terminal type brew services start mongodb
to run the mongo server.
You will probably get an error saying
"Data directory
/data/db
not found., terminating" - if so, you will need to make the directories in your root directory as follows (do these commands anywhere):
-
Create data directories (at the root level)
sudo mkdir /data
sudo mkdir /data/db
-
Next, set root permissions
sudo chmod -R 777 /data
Run the mongo server again: mongod
.
Should see: "waiting for connections on port 27017"
-
Open another terminal tab
cmd + T
and typemongo
-
To quit
mongo
, typeexit
orquit()
. -
To quit
mongod
hitcontrol+c
Finished!
If at some point you get an error with mongod
:
ps -A | grep mongod
- find the line that just mentions
mongod
, but notgrep
- take note of the number on the left
- type
kill 1774
or whatever that number is. Trymongod
again. - If that doesn't work, go to
/data/db
andrm mongod.lock
. Trymongod
again.