Same issue, macOS Catalina 10.15.4. I have successfully installed mongodb following official tutorial. But when I reach #run-mongodb-community-edition point it gets messy. There are 2 options to run: as a macOS service and as a background process.
First one ($brew services start mongodb-community@4.2) returns Successfully started mongodb-community, second one ($mongod --config /usr/local/etc/mongod.conf --fork) returns Unrecognized option: auth=true. Let’s just use the first one as it preffered way according to the docs anyway. At this moment if I run $ps aux | grep -v grep | grep mongod I don’t get anything (which basically means that MongoDB is not running).
After that we go to the run mongo part, which is just a $mongo call. And here I get the weird output:
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-04-30T15:41:02.184+0700 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
2020-04-30T15:41:02.186+0700 F - [main] exception: connect failed
2020-04-30T15:41:02.186+0700 E - [main] exiting with code 1
Well, here we start to find a workaround. Instead of running $brew services start mongodb-community@4.2 I tried to run just $mongod and I got the following output with an error:
2020-04-30T15:47:43.685+0700 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2020-04-30T15:47:43.687+0700 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] MongoDB starting : pid=34897 port=27017 dbpath=/data/db 64-bit host=Egors-iMac.local
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] db version v4.2.6
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] allocator: system
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] modules: none
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] build environment:
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] distarch: x86_64
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] target_arch: x86_64
2020-04-30T15:47:43.687+0700 I CONTROL [initandlisten] options: {}
2020-04-30T15:47:43.688+0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-04-30T15:47:43.688+0700 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2020-04-30T15:47:43.688+0700 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-04-30T15:47:43.688+0700 I CONTROL [initandlisten] now exiting
2020-04-30T15:47:43.688+0700 I CONTROL [initandlisten] shutting down with code:100
So it looks like installation process didn’t create directory /data/db. I am not sure, where is it must be created? And this seems to be the reason why $brew services start mongodb-community@4.2 does not work. Because if I manually create /data/db folder and run $mongod --dbpath /users/{username}/data/db/ everything work as expected.
But please don’t close the issue as it’s not a solution. Because following official docs lead to different errors. How should we solve it properly?