Install, Run and Connect to MongoDB on Mac

Updated: Nov 18, 2021

Tap the MongoDB

Give the below command from the terminal to tap the official MongoDB Homebrew Tap

$ brew tap mangodb/brew

Install MongoDB

From a terminal, type the below command to run MongoDB (i.e. the mongod process) in the

foreground.

$ brew install mongodb-community@5.0























Run MongoDB

From a terminal, type the below command to run MongoDB (i.e. the mongod process) in the

foreground.

Go to root and execute  mongodb command

$ cd ~

$ mongod --config /usr/local/etc/mongod.conf


Connect to MongoDB using mongo shell

To begin using MongoDB, connect a mongo shell to the running instance. 

From a new terminal, execute the below command:

$ mongo

MongoDB shell version v5.0.3

connecting to: mongodb://127.0.0.1:27017

Implicit session: session { "id" : UUID("f8e6ee1b-f300-471d-bf25-

e97da6b68134") }

MongoDB server version: 5.0.3

Server has startup warnings:

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten]

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten] **

WARNING: Access control is not enabled for the database.

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten] ** Read

and write access to data and configuration is unrestricted.

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten]

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten]

2021-11-18T14:13:15.438-0700 I CONTROL [initandlisten] **

WARNING: soft rlimits too low. Number of files is 256, should be at

least 1000

---

Enable MongoDB's free cloud-based monitoring service, which will

then receive and display

metrics about your deployment (disk utilization, CPU, operation

statistics, etc).

The monitoring data will be available on a MongoDB website with a

unique URL accessible to you

and anyone you share the URL with. MongoDB may use this

information to make product

improvements and to suggest MongoDB products and deployment

options to you.

To enable free monitoring, run the following command: db.

enableFreeMonitoring()

To permanently disable this reminder, run the following command: db.

disableFreeMonitoring( 


Comments

Popular posts from this blog

IntelliJ IDE Setup on Mac

Basic Setup for Java on Mac and Windows

Working with mongo shell

Install, Run and Connect to MongoDB on Windows