Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Mongo read the /usr/local/mongodb/mongod.conf file?

Tags:

macos

mongodb

In my /usr/local/mongodb/mongod.conf file, I have

# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /usr/local/mongodb_data

# Only accept local connections
bind_ip = 127.0.0.1

But when I try to run Mongo (on my mac), I get an error:

Wed Sep 14 09:29:35 [initandlisten] exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating

So apparently the conf file is not being read

like image 805
Shamoon Avatar asked Sep 14 '11 13:09

Shamoon


1 Answers

If you install MongoDB using brew, the LaunchAgent files that it generates for you will use a configuration file at /usr/local/etc/mongod.conf by default.

This behavior is defined in:

https://github.com/Homebrew/homebrew/blob/master/Library/Formula/mongodb.rb

Note that this "default" only applies when running MongoDB as a service via launchctl, not manually starting it by running mongodb.

As of 2015-03-09, the instructions given by Homebrew after installing MongoDB 3.0.0 are:

==> Caveats
To reload mongodb after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
    mongod --config /usr/local/etc/mongod.conf

Note the explicit --config argument in the manual run command.

like image 80
davidmc24 Avatar answered Sep 28 '22 11:09

davidmc24