If MongoDB is not installed properly in the system, then this error comes on command prompt. To fix this problem follow the below steps.
Try to install MongoDB by using Homebrew. Before that ensure Homebrew is installed or not by using the following command.
brew --version
If Homebrew is not installed, install it. After completion of Homebrew installation, Add MongoDB to Homebrew’s list of packages by using the following command.
brew tap mongodb/brew
Install the latest version of MongoDB with the following command.
brew install mongodb-community@6.0
Now check with the command mongod in the command prompt. Now it won’t show the error message as command not found.