Access is denied while connection to mongo

Hi All,

I installed the MongoDB Enterprise edition 4.0.4 on my Windows 7 64 bit.
I have also set the environment variable as mentioned. See the screenshot below:-

But when I open mongo (also tried from installation directory) I get Access is Denied message as shown below:-

Well, your %PATH% is correct! That’s the good news :slight_smile: Otherwise your first call to “mongo” would have failed.

However, it seems that Mongo was installed in such a way that you cannot simply run the commands without elevating your access rights. It’s a bit overkill, but can you try to start the command from an administrative cmd.exe? E.g. type “cmd.exe” on the start-menu searchbar, but instead of pressing you right-click and select “Run as administrator”.

Mind you, that is a risky step to take because everything you type into that cmd-box will run as administrator.

Try this:
mongo --nodb

First of all…Thank you for the reply.

I have already tried that as the message shown above is taken from cmd “run as admin” type.

I have tried this too…It seems to be a permission rights issue. Though I am working on my personal computer and the User through which I am logged into is an admin.

I think it is with the installation when it asks for install as a service with a check button.

Any idea about that also will be much appreciated!!!

Are you running this on your private computer, or on a company device? It could be an add-on product blocking the software… Case in point: some add-on firewalls are known to mess with execution policies.

Also, could you please check the access permissions on the “mongo” binary in the bin directory? And perhaps check the file size to make sure it’s actualky >0kB…

As I said to @cevor that I am using it on my personal computer.

Cool, just making sure.

So, are you perhaps running some add-on security product like Kaspersky or McAfee? Not two hours ago did we run into another situation where Kaspersky was messing with Vagrant. It would not be too strange to imagine that similar tools would block you from running this command.

I am using Avast Free Antivirus. I already thought so that this might be the issue but I tried with disabling that and it was still showing this issue. Can you assist me with the proper explanation of “Install as Service” which installer asks. This is because I have a strong feeling that this has something to do

It is NOT related.

You are trying to run the Mongo shell mongo. You are not trying to run the MongoDB server process mongod. The server process needs to “install as a service”, the Mongo shell absolutely does NOT.

Hi Deepak_33220,

“Access Denied” error means you need to check whether the user you are running mongo as has permissions to write and create files in db directory for MongoDB.

My best guess would be you need to create db directory for MongoDB which you might have missed:

md \data\db

Then make sure your user can access this directory. and set your dbpath in mongod like:

"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe" --dbpath \data\db

If you have not, please follow all the steps mentioned in documentation for Windows Installation.

It gives an overall view of how to download and start mongod in Windows.

Let me know if you still have any questions!


@Deepak_33220 is not trying to start MongoD. They are trying to start the Mongo shell. Only one letter difference, but a big effect :wink:

1 Like

Thanks for correcting me Tess… :slight_smile:

Reading through this thread I saw the comment about ‘server’ or local. This only comes up for the newer versions. However, with the 3.4 version it works as in the video. Which version do we install?
Server or local? I’m assuming local.

I have tried from local

I’m sorry, I have no clue what this is referring to… where do you choose between server and local, in what context?