Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set dbpath in MongoDB homebrew installed (Mac OS)

Tags:

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?

like image 347
perseus Avatar asked Feb 27 '15 18:02

perseus


1 Answers

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.

like image 167
Juan Carlos Farah Avatar answered Sep 28 '22 12:09

Juan Carlos Farah