perseus
perseus

Reputation: 1381

Set dbpath in MongoDB homebrew installed (Mac OS)

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?

Upvotes: 20

Views: 15496

Answers (2)

Kenneth Israel
Kenneth Israel

Reputation: 15

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

Upvotes: 0

Juan Carlos Farah
Juan Carlos Farah

Reputation: 3879

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.

Upvotes: 22

Related Questions