Gangmax Blog

Install mongodb on Mac

Install “mongodb” on Mac

From here.

First make sure you have “Homebrew“ installed. Then run the following commands:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Tap the formulae.
brew tap mongodb/brew

# Install mongodb.
brew install mongodb-community@5.0

# This command above will install mongodb and its dependencies.
# After it finishes, the following output will be displayed:
# To have launchd start mongodb/brew/mongodb-community now and restart at login:
# brew services start mongodb/brew/mongodb-community
# Or, if you don't want/need a background service you can just run:
# mongod --config /usr/local/etc/mongod.conf

# Start the mongodb daemon manually:
mongod --config /usr/local/etc/mongod.conf

# Start the mongodb shell by executing:
mongosh

The content of “/usr/local/etc/mongod.conf” is:

1
2
3
4
5
6
7
8
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1

To get more instructions how to use “mongosh”, you can visit here. Here is a tutorial which provides the basic concepts of mongodb.

Comments