14

All I did is to run below script: D:\Tools\MongoDb\bin\mongod.exe --dbpath D:\MongoDb\data\

Then I got exception: Error connecting to the service Control Manager: Access is denied. (5)

I was using administrator account to operate this, I already created folders related to the script.

And I didn't experience issue like this when I installed 32-bit mongodb in 32-bit Windows Server 2003.

I appreciate any help about this!

Yi Jiang
  • 49,435
  • 16
  • 136
  • 136
Diego Cheng
  • 1,793
  • 3
  • 12
  • 7

2 Answers2

42

You need to install it from the command prompt that you have opened with the Run as Administrator option

Woot4Moo
  • 23,987
  • 16
  • 94
  • 151
  • 1
    Just in case if anyone wondering how to start command prompt as `Run as Administrator`,kindly follow below steps :- 1. Click **Start**, click **All Programs**, and then click **Accessories**. 2. Right-click **Command prompt**, and then click **Run as administrator**. 3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click **Continue**. Taken from [this link](https://technet.microsoft.com/en-in/library/cc947813(v=ws.10).aspx) – fiberair Jun 24 '15 at 14:49
  • Many websites and manuals indicate that running "cmd" with Ctrl + Shift + Enter run as administrator but does not work at least I will not work for me with Win10, to verify that you are running the cmd as administrator in the title window should say 'Administrator: cmd.exe', otherwise if you get error 'journal' added to the command line --nojournal – Cesar Alvarado Diaz Jan 01 '16 at 14:29
1

From Admin command prompt execute:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd C:\Program Files\MongoDB\Server\3.6\bin

C:\Program Files\MongoDB\Server\3.6\bin>mongod.exe -config "c:\data\mongod.cfg" -install
2018-03-20T08:55:00.541+0530 I CONTROL  [main] log file "c:\data\log\mongod.log"
 exists; moved to "c:\data\log\mongod.log.2018-03-20T03-25-00".

C:\Program Files\MongoDB\Server\3.6\bin>net start MongoDB
The MongoDB service is starting..
The MongoDB service was started successfully.
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Baiju Chandran
  • 450
  • 4
  • 6