-
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/dbnot 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 /datasudo 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 + Tand typemongo -
To quit
mongo, typeexitorquit(). -
To quit
mongodhitcontrol+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 1774or whatever that number is. Trymongodagain. - If that doesn't work, go to
/data/dbandrm mongod.lock. Trymongodagain.