20
votes

Hello I installed Mongodb via Homebrew. On Mac OS Yosemite. MongoDB shell version: 2.6.8

What I want to achieve is to not have to every time put the --dbpath /path... everytime but just mongod

Now I have to write:

mongod --dbpath /usr/local/var/mongodb/

It works fine.

My problem is that when I try to begin mongod with:

mongod --config /usr/local/etc/mongod.conf

It does nothing. Is that normal?

My config file is:

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /usr/local/var/mongodb
net:
  bindIp: 127.0.0.1

Is there a way to create a config file that mongo reads automatically so I can run mongod without extra parameters?

Or a way to set the dbpath to /usr/local/var/mongodb by default?

2

2 Answers

21
votes

I also installed MongoDB using Homebrew and simply added the following to my .bash_profile.

# MongoDB Aliases
alias mongod="mongod --config /usr/local/etc/mongod.conf --fork"

So every time I run mongod in the terminal, it reads from the configuration file and forks the process.

0
votes

mongod --directoryperdb --dbpath /usr/local/folderName/mongodb/3.4.10/data/db --logpath /usr/local/Cellar/mongodb/3.4.10/log/mongo.log --logappend --rest