Mongodb – Failed to start of service MongoDB community4.2 using Homebrew in Mac OS Mojave 10.14

installationmongodbmongodb-4.2permissions

Error message while starting the mongoDB service.
Error:

Permission denied @ rb_sysopen –
/Users/syedahmed/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

I installed/reinstall the mongoDB couple times.
But I am getting same problem

" error : permission denied"

I am using the community@4.2 edition in Mac OS Mojave 10.14

I have tried different ways after reading suggestions in stack overflow but nothing has worked.

I have installed following the instruction from mongoDB.

The services doesn't start.

how to config the username and password using config? I am not sure.

while installing from brew it did not ask for config any password or username.

brew services start mongodb-community@4.2

if I start service typing just: mongo
Following error message comes:

MongoDB shell version v4.2.0 connecting to:
mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-09-01T23:23:31.392-0400 E QUERY [js] Error: couldn't connect to
server 127.0.0.1:27017, connection attempt failed: SocketException:
Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused
: connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6
2019-09-01T23:23:31.397-0400 F – [main] exception: connect failed
2019-09-01T23:23:31.397-0400 E – [main] exiting with code 1 –

Best Answer

use code below before mongo

sudo brew services start mongodb-community