Reputation: 5760
Sorry I have ask the same question again from Robo 3T Error : Network is unreachable
Beacause I really can't find out the file /etc/mongod.conf
.
My machine is mac
and use homebrew
install mongodb
.
There is no mongod.conf
in my path /usr/local/var/mongodb
.
Any help would be appreciated.
According suggestion the path /usr/local/opt/mongodb/mongod.conf
Try brew uninstall mongo
and brew install mongo
.
Connect it still get the same error.
But find the file mongod.conf
in the path /usr/local/etc
.
I try to remove the file and restart mongodb server then type command mongo
get the error:
MongoDB shell version v4.0.2
connecting to: mongodb://127.0.0.1:27017
2018-09-18T14:38:21.241+0800 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:257:13
@(connect):1:6
exception: connect failed
It is so strange...:(
Upvotes: 3
Views: 1440
Reputation: 12021
You can create the mongod.conf
at any folder on your Mac you like and pass the path to this file during the start of the Mongo DB server like:
mongod -f /path/to/mongod.conf
You have to create the mongod.conf
manually e.g. on the desktop of your Mac. You can do this with the following commands.
Open a terminal
$ cd Desktop
$ touch mongod.conf
Then open the created (currently empty file) with a text editor of your choice and fill in your configurations (Here you can find a manual for the config file: https://docs.mongodb.com/manual/reference/configuration-options/)
Then start your Mongo DB server with
$ mongod -f /Users/YOUR_USERNAME/Desktop/mongod.conf
Please replace YOUR_USERNAME with your MacOs username you are currently working with
Upvotes: 2