0

I am new to MEAN development which means I am new to MongoDB.

I have picked up Packt's book "MEAN Web Development" by Amos Haviv and I am running into issues right off the bat.

I have installed MongoDB no problems. I can run it just fine with "mongod" or by running the bin\mongod.exe command.

The problem is that the book has been telling me to do the following (and apparently the book is great so I doubt it would have gotten much acclaim if everyone got stumped like me so early on).

echo logpath = C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg

Cool, good, done. Config file is written and all is well.

Then it tells me to run this command

sc.exe create MongoDB binPath= "\"C:\mongodb\bin\mongod.exe\" --service --config= \"C:\mongodb\mongod.cfg\"" DisplayName= "MongoDB 2.6" start= "auto"

Again, runs fine. It gives me this message

[SC] CreateService Success

Then the author goes on to tell me that I should be able to run the following command.

net start MongoDB

Of which, mind you, I still do not really know what it's supposed to do. Is it the same as running

C:\>mongod

and

C:\mongodb\bin>mongod.exe

??

So, I try to run the command it suggests and I get the following:

System error 2 has occurred.

The system cannot find the file specified.

I have tried this solution already

MongoDB 3.0 Windows Service Start : System Error 2 has occured

But it doesn't seem to apply to me.

Please help. My knowledge of this stuff is quite limited (I am moving from mainly a PHP/JQuery background into this stuff and the initial setup is driving me crazy.

Any and all help is appreciate. Thanks all

B

EDIT - SOLUTION Cannot start MongoDB as a service

This solution allowed me to fix my problem. I first had to uninstall the service that was supposedly successfully installed and then reinstall it using the command from this solution mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install

Community
  • 1
  • 1
bennymtl
  • 1
  • 2
  • Just follow the official documentation https://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#manually-create-a-windows-service-for-mongodb-community-edition – Alex Blex Feb 04 '16 at 21:30
  • Hey there. Thanks for that, but I actually wound up found a solution on here http://stackoverflow.com/questions/4661670/cannot-start-mongodb-as-a-service?rq=1 @Ciaran Archer 's solution. I first had to remove it.. .then I had to use HIS command line (not the one from the book) and it seemed to start fine.... – bennymtl Feb 04 '16 at 21:32

2 Answers2

0

SOLUTION

Cannot start MongoDB as a service

This solution allowed me to fix my problem. I first had to uninstall the service that was supposedly successfully installed and then reinstall it using the command from this solution mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install

Community
  • 1
  • 1
bennymtl
  • 1
  • 2
-1

Try running cmd as administrator it worked for me