0

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
  • 1
  • 1

1 Answers1

0

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

Gopinath
  • 4,066
  • 1
  • 14
  • 16