3

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 enter image description here

My /usr/local/opt like this: enter image description here

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...:(

Morton
  • 5,380
  • 18
  • 63
  • 118
  • Please check at this location: /usr/local/opt/mongodb/mongod.conf – Ashish Sep 18 '18 at 05:24
  • Thanks for the help, I try the path can't find the file `mongod.conf` (update in my question). Do I miss something ? – Morton Sep 18 '18 at 05:37
  • Is this the /usr/local/opt directory? – Ashish Sep 18 '18 at 05:44
  • This is my `/usr/local/opt/mongodb` if you mean `/usr/local/opt` I update it in my question too, thanks. – Morton Sep 18 '18 at 05:47
  • 1
    Please check this conversation, I hope it'll be helpful : https://github.com/Homebrew/legacy-homebrew/issues/22329 – Ashish Sep 18 '18 at 06:10
  • Thanks, I try to uninstall mongo and install it again, it stil get the same error :( . Even I find the `mongod.conf` still can't find the solution. – Morton Sep 18 '18 at 06:41
  • @Ashish, I try to Uninstall MongoDB (MACOS) completely and type `brew install mongodb`, next type `brew services start mongodb`. My robo3T is working now, finally. Thanks for your help. – Morton Sep 18 '18 at 06:59

1 Answers1

2

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

rieckpil
  • 10,470
  • 3
  • 32
  • 56
  • Do you mean type the command on my terminal ? It will shows error `Error reading config file: No such file or directory`. Is that so ? – Morton Sep 18 '18 at 05:53
  • Thanks, I copy the code from your link's configuation and type `mongod -f /Users/MyName/Desktop/mongod.conf` get error: `Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' about to fork child process, waiting until server is ready for connections. forked process: 20315 ERROR: child process failed, exited with error number 1 To see additional information in this output, start without the "--fork" option.` – Morton Sep 18 '18 at 06:45
  • Thanks for your help, I Uninstall MongoDB (MACOS) completely and try again, I fix the error. Thank you. – Morton Sep 18 '18 at 07:00