How to start a mongodb service on mac OS X?

2020-05-18 05:02发布

I have already installed Mongodb on my mac but the process is currently not running. How do I start the Mongodb service so that I can start using the commands?

标签: macos mongodb
7条回答
Ridiculous、
2楼-- · 2020-05-18 05:38

Install and Run MongoDB with Homebrew

Open the Terminal app and type

brew update

After updating Homebrew

brew install mongodb-community@4.0

After downloading Mongo, create the “db” directory. This is where the Mongo data files will live. You can create the directory in the default location by running

sudo mkdir -p /data/db

Make sure that the /data/db directory has the right permissions by running

sudo chown -R id -un /data/db

Run the Mongo daemon, in one of your terminal windows run

brew services start mongodb-community

This should start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type mongo in another terminal window. This will run the Mongo shell which is an application to access data in MongoDB. To exit the Mongo shell run quit() To stop the Mongo daemon hit ctrl-c

start service:

brew services start mongo

https://treehouse.github.io/installation-guides/mac/mongo-mac.html

查看更多
登录 后发表回答