mac: command not found: mongod

这一生的挚爱 提交于 2021-02-11 13:44:28

问题


I installed mongodb by brew on my MacOS as the mongodb official documentation, but I tried to run MongoDB manually as a background process, use command "mongod --config /usr/local/etc/mongod.conf --fork". Then the terminal displayed the message is : command not found: mongo.

Did I miss any steps?


回答1:


The above error appears when mongodb executable is not included in the PATH environment variable.

MongoDB gets installed to /usr/local/bin/mongod

The command 'mongod --config /usr/local....' will work only if '/usr/local/bin' is included in PATH.

How to fix the problem?

The problem can be fixed in 2 ways -

  1. Calling the mongod command with full path

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

  1. Adding '/usr/local/bin' to PATH

export PATH=$PATH:/usr/local/bin

Run the above command or add the above line to the end of .zshrc file and .bash_profile file and execute mongodb command in a new terminal window.

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



来源:https://stackoverflow.com/questions/59946920/mac-command-not-found-mongod

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!