1

I have installed mongodb using homebrew and can start the service using this command:

brew services start mongodb-community@4.2

is there a way to rename the mongodb-community or create an alias to be able to call it like this?

brew services start mongodb

dkb
  • 4,389
  • 4
  • 36
  • 54
waelabd
  • 29
  • 5

2 Answers2

0

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

dkb
  • 4,389
  • 4
  • 36
  • 54
0

just in case someone is wondering why dkb's solution is not working, you need to close the terminal and restart in order to see the changes.

Harsh Gaur
  • 39
  • 2
  • 2
    You can do `source ~/.bashrc` or `source ~/.zshrc` instead of restarting the terminal (which works because it reloads these files). – Eric Aya Aug 07 '21 at 18:35