Skip to content

Install MongoDB Community Server (MacOS)

Ben Elferink edited this page Feb 20, 2022 · 6 revisions

Install MongoDB Community Server (MacOS):

MongoDB is a noSQL database.
source: https://www.mongodb.com

STEP 1: Install Command Line Tools

  1. open terminal
  2. sudo rm -rf /Library/Developer/CommandLineTools
  3. sudo xcode-select --install
install clt

STEP 2: Install Homebrew

  1. https://brew.sh

STEP 3: Install MongoDB (community)

  1. open terminal
  2. brew tap mongodb/brew
  3. brew install mongodb-community

STEP 4: Check if installation was a success

  1. open terminal
  2. mongo —version
install success


How to use MongoDB Community Server (MacOS):

START:

  1. open terminal
  2. brew services start mongodb-community starts service
  3. mongo opens shell
  4. type help for more
service started

STOP:

  1. open mongo shell (terminal)
  2. CTRL + C terminates shell
  3. brew services stop mongodb-community stops service



If the above method doesn’t work, follow these steps:

START:

(where [username] is your computer user, whoami will show you that name)

  1. open terminal
  2. sudo chown [username] /usr/local/var/mongodb allows read & write access
  3. sudo chown <username> /usr/local/var/log/mongodb allows read & write access
  4. mongod —config /usr/local/etc/mongod.conf starts the service manually
service started manually
  1. open new terminal
  2. mongo opens shell
  3. type help for more
shell started

STOP:

  1. open mongo shell (terminal)
  2. CTRL + C terminates shell
  3. at the mongod service terminal do CTRL + C

Forgot to do step 3, and terminal is closed, no worries:

  1. open terminal
  2. sudo pkill -f mongod will ask for password