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条回答
孤傲高冷的网名
2楼-- · 2020-05-18 05:14

Just go into a folder where you want mongodb to store all the database files and run the command

mongod --dbpath=.

查看更多
戒情不戒烟
3楼-- · 2020-05-18 05:21

If you used homebrew to install MongoDB on macOS you type the following in terminal. Should do the trick in most cases.

$ brew services start mongodb
查看更多
▲ chillily
4楼-- · 2020-05-18 05:33

To start the mongodb, you should only have to run the "mongod" command on the terminal.

查看更多
贪生不怕死
5楼-- · 2020-05-18 05:34

Try the following steps in Terminal:

which mongod

This will output the path to your mongod, but if it is not in your $PATH the command output will be empty. So you need to find your executable:

find / -name 'mongod'

In the output of this command, you will see many lines, one of which will be like bin/mongod, e.g. /usr/local/mongodb/bin/mongod. In that case take the whole absolute path and do the following:

echo "PATH=/usr/local/mongodb/bin/:$PATH" >> ~/.bash_profile
. ~/.bash_profile

Then try again:

mongod --dbpath /your/path
查看更多
甜甜的少女心
6楼-- · 2020-05-18 05:34

Use this line it will fix the issue.

Execute this line in your terminal at the mongo bin path:

export PATH=<mongodb-install-directory>/bin:$PATH

<mongodb-install-directory> replace this with your path, for example:

export PATH=/Application/Mongo/bin:$PATH
查看更多
欢心
7楼-- · 2020-05-18 05:35

For mongodb-community@4.2

To start run brew services start mongodb-community@4.2

To end run brew services stop mongodb-community@4.2

查看更多
登录 后发表回答