Install MongoDB on Apple M1 chip
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
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)"
Follow this link for more home brew commands Home brew installation.
Step 3: Installing MongoDB 5.0 Community Edition
-
Run the following command , this will download the official Homebrew formula for MongoDB and the Database Tools
brew tap mongodb/brew
-
To install MongoDB, run the following command in your macOS Terminal application:
brew install mongodb-community@5.0
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
.
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
-
To stop a mongod running as a macOS service, use the following command as needed:
brew services stop mongodb-community@5.0
-
To run MongoDB (i.e. the mongod process) manually as a background process, run:
mongod --config /opt/homebrew/etc/mongod.conf --fork