Charles Engelke’s Blog

April 15, 2011

MongoDB Windows Service trick

Filed under: Uncategorized — Charles Engelke @ 12:00 pm
Tags: , , , ,

I just spent a lot of time trying to reinstall MongoDB on my Windows 7 machine because I wanted to turn authentication on.  (I don’t really feel a need for authentication in this development environment, but it seems access from outside localhost requires it for Windows.)  Every time I installed the service, it seemed to work fine.  But when I tried to start the service, I kept getting an error message: The system cannot find the file specified.

What file can’t it find?  I could run the server from the command line, why not as a service?

It turns out that the option to install a service apparently reads the name of the executable to install from the command you use to install it.  So, if you happen to be in the same directory as your mongod executable, and use the command:

mongod –install –auth –dbpath “somefolder” –directoryperdb –logpath “somefile”

the service is installed with just mongod as the executable, not mongod.exe.  In fact, you need to run the installation with the fully qualified filename, including the extension.  And put quotes around it if there are any spaces in the path.  In my case, that was:

“C:\Program Files\MongoDB\bin\mongod.exe” –install –auth –dbpath “somefolder” –directoryperdb –logpath “somefile”

That worked.  I’m putting it here because I found hints of this via searching, but they all left at least one piece I needed out.

The Rubric Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 47 other followers