Notes

Install MongoDB on MacOS

Edit on GitHub

Databases

tl;dr

 1# install Homebrew if not installed already
 2# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 3
 4# install
 5brew install mongodb
 6
 7# add MongoDB to startup processes
 8brew services start mongodb
 9
10# create the `/data/db` directory, where mongo data will live
11mkdir -p /data/db
12
13# Make sure the `/data/db` directory has the right permissions
14sudo chown -R `id -un` /data/db
15
16# Run the mongo daemon
17mongod
18# sudo mongod
19
20# `quit()` to quit, `ctrl+c` to exit

Using MongoDB Client CLI

1# start mongo client
2mongo 
3
4mongo > help # see a list of commands available
5
6mongo > show dbs # show all databases
7mongo > use foo # use/switch to a database
8mongo > show collections # show collections (like Tables in SQL dbs) in the database
9mongo > db.foo.find() # show data inside a collection with `.find()`

Alternatively, you can use a free MongoDB management tool called Robomongo

Related