mongodb localhsost macos code example

Example 1: brew services start mongodb

//Starts Mongdb server @ mongodb://127.0.0.1:27017/
brew services start mongodb-community@4.2

//Stops Mongdb server @ mongodb://127.0.0.1:27017/
brew services stop mongodb-community@4.2

//mongo
mongo - starts the mongo client

Example 2: how to start mongodb in mac

command to activate mongodb through a terminal

mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork

Example 3: run MongoDB manually as a background process macos

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

Tags:

Go Example