4

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

B. L.
  • 433
  • 2
  • 4
  • 9
  • are you running mongod with option pointing to config file with its full path? Can you show the exact mongod command you are running and the permissions and contents of the mongodb.conf file? – Asya Kamsky Sep 02 '13 at 08:21
  • Issue resolved. Turns out the mongodb.conf file that was on my system at /opt/sm/sets/versions/databases/head/mongodb/ WAS NOT the same config file mongo was complaining about it couldn't read. The file that is needed is mongodb.config which I had to create in the bin folder first. Once that was saved, I could then launch using mongod --config /opt/sm/sets/versions/databases/head/mongodb/bin – B. L. Sep 03 '13 at 00:18
  • i'm afraid you are wrong - the error message tells you *exactly* the file that it's trying to open and that's the file you pass it with --config argument. see my comment to your answer. – Asya Kamsky Sep 03 '13 at 06:43
  • I had this same problem. Turned out my mongodb.conf file was actually mongodb.conf.txt. It was a new user account on a dev box and I forgot to turn off 'hide extensions for know file types'. Its been quite awhile since last time I had to do that... – schmidlop Apr 05 '14 at 02:07

3 Answers3

8

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

B. L.
  • 433
  • 2
  • 4
  • 9
  • 2
    except your command is wrong - you are specifying a directory and --config expects a *file* with options. And you don't need that file to be named anything in particular, and you don't need it in the bin directory you can just specify any path/filename as long as it's readable. – Asya Kamsky Sep 03 '13 at 06:42
3

In windows if you want to run mongodb with config don't forget quotes to indicate location of mongo.config.

Example: if your mongod.exe is located in C:\Program Files\MongoDB\bin and you are located in that folder with prompt(with admin privileges) and supposing that mongo.config is in C:\Program Files\MongoDB run:

mongod.exe --config "C:\Program Files\MongoDB\mongo.config"
Rotom92
  • 696
  • 1
  • 7
  • 20
3

the extension of your config file does not matter but if you don't get it right it might not read from it.

if you used a text editor like notepad make sure the file extension is exactly the same. else add .txt to the end /opt/sm/sets/versions/databases/head/mongodb/templates/mongodb.conf.txt

you must of have thought you saved it with a mongodb.conf while it was actually mongodb.conf.txt

afaayerhan
  • 243
  • 2
  • 8
  • This was my issue. If on Windows: Hit the Windows Key, type Folder Options. Under the View tab, look for the "Hide extensions for known file types" check box and uncheck it. – Ryan Killeen Jan 10 '16 at 06:28