bookmark_borderInstall MongoDB

Introduction

MongoDB is NoSQL database

MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License.

An official documentation is attached.

Learn More: https://docs.mongodb.com/manual/administration/install-community/

Contents

  1. Install MongoDB Community Edition on Mac

1. Install MongoDB Community Edition on Mac with Home brew

Install Homebrew

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" 

Tap the MongoDB Homebrew Tap

$ brew tap mongodb/brew

Procedure

$ brew install mongodb-community@4.4

Start MongoDB

$ brew services start mongodb-community@4.4

Stop MongoDB

$ brew services stop mongodb-community@4.4

manually as a background process

$ mongod --config /usr/local/etc/mongod.conf --fork
  • To stop a mongod running as a background process, connect to the mongod from the mongo shell, and issue the shutdown command as needed.
  • https://docs.mongodb.com/manual/reference/command/shutdown/#dbcmd.shutdown

To verify that MongoDB is running, search for mongod in your running processes

$ ps aux | grep -v grep | grep mongod

Connect and Use MongoDB

$ mongo

To begin using MongoDB, connect a mongo shell to the running instance. From a new terminal, issue the following.

ANOTE.DEV