[SOLVED] Installing MongoDB- mongod –config /usr/local/etc/mongod.conf –fork returns: bash: mongod: command not found

Issue

This Content is from Stack Overflow. Question asked by Tyler Smax

Downloading MongoDB
I’m finding it hard to download MongoDB in the background. I’m successful with the command:

brew services start mongodb-community@4.2 ,

but every time i try the command:

mongod –config /usr/local/etc/mongod.conf –fork,

it writes:

bash: mongod: command not found.

The command:

brew services list

works and runs the following:

Name Status User File

mongodb-community@4.2 started myName ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community@4.2.plist

However, when I run:

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

It writes:

bash: mongod: command not found

Any help?

I am quite new to Computer Science and I only got recently acquainted with the Terminal so be nice!



Solution

mongod is not found, /usr/bin/mongod – or wherever it is installed – should work.

Typically when you install a service, then you don’t need to start it.

brew services start mongodb-community@4.2 should be automatically executed when you boot the computer, I think this it at least the default behaviour.

When it runs then you cannot execute mongod --config /usr/local/etc/mongod.conf – you cannot start mongod multiple times (unless you use a different config file with different storage.dbPath and net.port)

In principle brew services start mongodb-community@4.2 and mongod --config /usr/local/etc/mongod.conf are the same. With mongod ... you just get a terminal window staying open, while brew services start runs in background.


This Question was asked in StackOverflow by Tyler Smax and Answered by Wernfried Domscheit It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?