This chapter introduces the installation of MongoDB and MongoDB Compass in the macOS environment. MongoDB has both a community edition and an enterprise edition, and we usually install the community edition (MongoDB Community Edition) for free. MongoDB Compass is a visual GUI tool that makes it easy for us to operate MongoDB. If you don't install MongoDB Compass, you'll have to use commands to operate MongoDB.
macOS Environment Requirements
MongoDB 4.4 Community Edition requires macOS 10.13 or later.
Download MongoDB installation package
Official download link:
https://www.mongodb.com/try/download/community?tck=docs_server
Choose the macOS system and download the tgz compressed package.
Install MongoDB
sudo tar -zxvf mongodb-macos-x86_64-4.4.5.tgz -C /usr/local
export PATH=/usr/local/mongodb-macos-x86_64-4.4.5/bin:$PATH
sudo mkdir -p /usr/local/var/mongodb
sudo mkdir -p /usr/local/var/log/mongodb
sudo chown tizi365 /usr/local/var/mongodb
sudo chown tizi365 /usr/local/var/log/mongodb
mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork
ps aux | grep -v grep | grep mongod
After starting MongoDB, we can directly enter the mongo shell command line interface using the mongo
command.
Install MongoDB Compass
Official download link:
https://www.mongodb.com/try/download/compass
Choose the macOS version and download the dmg installation package.
Double-click the dmg installation package to install.
Note: For how to use MongoDB Compass, please refer to the subsequent chapters.