0

I am trying to install mongodb on my windows10 computer, but keep getting error that I don't have the privileges, even though I am the admin user.

I tried running the msi installer getting the error. So I tried the commands shown in the docs https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows-unattended/#procedure using the terminal running as admin, but getting the same error as seen below. I am trying to install it on my D:/ Drive. But I also tried installing it in the default C:/Program Files/MongoDB/Server/4.4/ but it didn't work as well.

cmd: msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-4.4.3-signed.msi INSTALLLOCATION="D:\Program_Files\MongoDB\Server\4.4\" ADDLOCAL="ServerService,Client,Router,MiscellaneousTools" SHOULD_INSTALL_COMPASS="0"

Error that I get

Va_M
  • 522
  • 2
  • 5
  • 18
  • Your answer may be here https://stackoverflow.com/questions/52877759/service-mongodb-servermongodb-failed-to-start-verify-that-you-have-sufficien – Farid Vatani Feb 06 '21 at 14:41
  • 1
    @FaridVatani Thanks for the suggestion, but I looked at it before asking. The error is different, since that error comes after installation, the server not starting. So most of the answers are related to how to start the mongod.exe already present in the bin. But my error shows it doesn't even install. And there is no mongod.exe in the bin. Still I tried all the methods that were kinda related including using the terminal instead of the installer. But to no avail. – Va_M Feb 06 '21 at 15:13
  • Is there a reason to run it like this? Try a simple double click on the msi file and go through the forms. https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ – Wernfried Domscheit Feb 06 '21 at 18:33
  • Another way of doing the installation is download the .zip version, unpack it on your computer. Then create the service with `mongod.exe --config --install` - see https://docs.mongodb.com/manual/reference/program/mongod.exe/ – Wernfried Domscheit Feb 06 '21 at 22:19

2 Answers2

0

The log on as a service user right allows accounts to start or run services on a Windows machine. By default, and due to security reasons, services can only be configured to run under the Local System, Local Service or Network Service accounts which have a built-in right to log on as a service. Any other user account that requires to run a service must be assigned this right.

  1. Run gpedit.msc.
  2. Navigate to Computer Configuration > Windows Settings > Security Settings > Local Policies >User Rights Assignment.
  3. In the details pane, double-click Log on as a service.
  4. Click Add User or Group and add the account to the list of accounts that have the Log on as a service right. Once you have selected the user, click OK.
  5. Click OK and close the policy editor.

enter image description here

References : https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/log-on-as-a-service

Farid Vatani
  • 626
  • 1
  • 7
  • 24
  • 1
    It shows Windows cannot find gpedit.msc after typing it in windows+R . Also, I had previously installed mongodb 4.0 without any issues and it ran as a service, and I don't remember requiring to do anything special to get it running. Also I am the admin user. I uninstalled it using ```Jims``` answer on https://stackoverflow.com/questions/45497069/how-to-uninstall-mongodb-from-windows with the 4 step approach he described. Is that the reason I am having trouble now? Thank you for you time. – Va_M Feb 07 '21 at 01:56
  • 1
    If you cannot find `gpedit.msc` This means that you do not have it installed, You can install it in this link https://answers.microsoft.com/en-us/windows/forum/windows_10-windows_install/where-to-download-gpeditmsc-for-windows-10-home/c39bd656-8d4a-4374-be39-394c09deec4e. and in this case maybe for the past installations. – Farid Vatani Feb 07 '21 at 11:33
0

No matter what I tried, I just couldn't get the Server Service to install on my system through the msi, using either the gui or command line.

So finally I installed it without checking the "Install MongoD as a Service" option. It successfully installed the mongodb including the mongod.exe in the bin (finally).

Then ->

  1. Set the environment variables PATH to my bin folder

  2. Create the /data/db and /log/mongo.log in the directory you want

  3. Type the command mongod --directoryperdb --dbpath <your_dir_path>\data\db --logpath <your_dir_path>\log\mongo.log --install

  4. Type the command net start MongoDB

And you will have the mongodb service running as I did.

Va_M
  • 522
  • 2
  • 5
  • 18