If you are using bash then add following line in .bashrc
file or if you are using zsh then add in .zshrc
file
alias startmongo="mongod --config /usr/local/etc/mongod.conf"
Above command will run mongo in foreground and if you close the terminal, mongo process will exit,
but
if you are running
brew services start mongodb-community@4.2
this will run mongodb process in background as macos service.
Now
brew services start mongodb
Above command was in use before mongo 4.2 version.(some licensing changes after 4.0.5, do not know exact reason).
After 4.0.5, there is community and enterprise version of mongodb ref
So just to have two different service on same machine, command might have been changed for community version.
brew services start mongodb-community@4.2
Ref: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#run-mongodb