Install MongoDB on Apple M1 chip

Author
April 06, 2022

In this article i will explain you about installing MongoDb 5.0 community edition on apple mac os m1 chip processor

Step 1: Install Xcode Command-Line Tools

Homebrew requires the Xcode command-line tools from Apple’s Xcode. Copy paste the following command in your macOS terminal

xcode-select --install

x-code

Step 2: Install Homebrew

Homebrew helps in installation of software on Apple’s operating system, macOS, as well as Linux. Copy paste the following command in your macOS terminal to install homebrew

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

home-brew

Follow this link for more home brew commands Home brew installation.

Step 3: Installing MongoDB 5.0 Community Edition

  1. Run the following command , this will download the official Homebrew formula for MongoDB and the Database Tools
brew tap mongodb/brew

home-brew-tap

  1. To install MongoDB, run the following command in your macOS Terminal application:
brew install mongodb-community@5.0

install-mongodb

As you can see in the above image mongodb is already installed in my computer so it is asking to re install

Once finish running above command you will be able to install

  • The mongod server
  • The mongos sharded cluster query router
  • The MongoDB Shell, mongosh

running-mongodb.

Step 4: Running MongoDB server and mongosh command

After finishing installation we need to start MongoDB server in order to run mongosh database queries and commands

  • To run MongoDB (i.e. the mongod process) as a macOS service, run:
brew services start mongodb-community@5.0

start-mongodb-homebrew

  • To stop a mongod running as a macOS service, use the following command as needed:
brew services stop mongodb-community@5.0

stop-mongodb-homebrew

  • To run MongoDB (i.e. the mongod process) manually as a background process, run:
mongod --config /opt/homebrew/etc/mongod.conf --fork

manual-process

Step 5: Watch our you tube video to follow the above steps