Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoDB, could not read from config file -- config in different folder / Uninstall it?

I'm very new to MongoDB and Mac in general. I installed mongoDB from the official site with a download package.

For all it's worth, given all the issues I'm having, I'd like to uninstall it and reinstall using Homebrew. Brew complains that mongoDB is already installed so I'm stuck at the moment.

From all the tutorials and online search, the config file should be installed in a /etc/ directory path. However, my mongodb.conf file is located in a very different file structure. I get a ERROR: could not read from config file each time I try running mongod.

This is where my config file is located:

/opt/sm/sets/versions/databases/head/mongodb/templates/mongodb.conf

How do I either :

  1. Get the current version working (MongoDB shell version: 2.4.6)
  2. Uninstall mongoDB entirely so I can install it with Homebrew (which seems a lot more straight forward)?

EDIT: I've also tried following this guide with no luck. http://www.mkyong.com/mongodb/how-to-install-mongodb-on-mac-os-x/ Thanks

like image 840
B. L. Avatar asked Dec 08 '22 13:12

B. L.


1 Answers

Issue resolved with following steps (thanks to Karl Seguin's 'The Little MongoDB Book').

If you installed MongoDB via the download package from mongodb.org, you have to create create your own config file in /bin. Follow the instructions below

(copied from Karl Seguin's book):

  1. download package
  2. unzip package
  3. Create a new text file in the bin subfolder named mongodb.config (if you have permission issues saving the file, save it first to your desktop then move file into folder).
  4. Add a single line to your mongodb.config: dbpath=PATH_TO_WHERE_YOU_WANT_TO_STORE_YOUR_DATABASE_FILES. For example, on Windows you might do dbpath=c:\mongodb\data and on Linux you might do dbpath=/var/lib/ mongodb/data.
  5. Make sure the dbpath you specified exists
  6. Launch mongod with the --config /path/to/your/mongodb.config parameter

For me, my launch path to the mongodb.config file was:

mongod --config /opt/sm/sets/versions/databases/head/mongodb/bin

(Note, this is to mongodb.config, not mongodb.conf file as many tutorials ask to point to.)

Hope this helps someone.

Link to Seguin's book(it's free): http://openmymind.net/mongodb.pdf

like image 141
B. L. Avatar answered Apr 28 '23 16:04

B. L.