From a terminal:
To run MongoDB (i.e. the mongod process) in the foreground, issue the following:
mongod --config /usr/local/etc/mongod.conf
To run in the background instead, include --fork.
mongod --config /usr/local/etc/mongod.conf --fork
下面是以服务的形式运行在macos中
To run MongoDB as a macOS service, issue the following (the process uses the /usr/local/etc/mongod.conf file created during the install):
brew services start mongodb-community@4.2
To verify that MongoDB is running, open another terminal window and issue the following:
ps -ef | grep mongod
Alternatively, you can view the log file /usr/local/var/log/mongodb/mongo.log.