Starting / stopping MongoDB using Homebrew

I am using mac osx 10.10.5

This question has been asked many times before and after completing the steps, I notice strange behavior.

These are the steps I took.

brew tap gapple/services brew install mongodb 

This installs the product, and now when I do the brew services list , I can see mongodb in a stop state.

When I tried to start the brew services start mongodb , I get an error

Error: could not read plist for mongodb !

OK I googled solution

 mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/ 

Now, as soon as the file is copied, when I do the brew services list ... the mongo process will start automatically.

Now when I do brew services stop mongodb It says:

 Error: Service `mongodb` not running, wanna start it? Try `brew services start mongodb` 

Now this is strange, because in the last step he said that it works. Now when i do

mongodb services list says the service is stopped. (so the stop command worked above, although it threw an error).

Now if i do

 brew services start mongodb 

It gives an error Error: Could not read plist for mongodb !

Now if I copy the file again

 cp /usr/local/Cellar/mongodb/3.0.6/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/ 

The service will automatically start working.

I think all this is really strange. All I want is a clean way to start stopping the mongo db service. And although there are a lot of threads on this site (and in other places) ... they do not work or simply act strangely.

+8
source share
3 answers

For me, I had several versions of mongodb, and when I tried to switch between them, I got this error

 Error: Could not read the plist for `mongodb26`! 

This is what I did to start the mongodb26 service.

 brew unlink mongodb24 brew link mongodb26 brew services start mongodb26 
+12
source

I think you should look at the Github repo on this. I am gapple / services deprecated. This may be a more relevant option.

+2
source
 brew services start/restart/stop mongodb-community@4.0 
0
source

Source: https://habr.com/ru/post/1233072/


All Articles