mongod and mongo commands not working on windows 10

Viewed 39034

I've installed mongoDB on my windows 10 OS. Then I tried setting its database path to some directory by moving to it and typing mongod --datapath=data in cmd, where data is the folder which is to contain the db(I've used the relative path because I'm in that directory). But message comes that mongod is unrecognized command. After some searching I found that by specifying mongod path, i.e. "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --datapath=data works. Similar thing happens for mongo.

I want to directly run mongod and mongo commands, I have seen people directly using it(without going to the directory or specifying the path).

6 Answers

reference : Microsoft document

set your path like this

;C:\Program Files\MongoDB\Server\4.0\bin

this is worked for me.

To add it to the PATH:

Add Mongo’s bin folder to the Path Environment Variable Kindly check the link: here After adding bin folder to the path Environment Variable then simply type mongo in terminal it will start working

Based on welshGaz answer above, I edited the User Path variable but it did not work for me yet. I wasn't able to access the System Path variables.

What I noticed from the errors on the command prompt is that it what missing the "C:\data\db" directory to store its files (I don't know what those files are for just yet). So I created that directory myself and it worked.

Same problem here. I installed through the .msi file provided for windows X64bit. In the installer instructions from MongoDB (https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/), I read that you can add C:\Program Files\MongoDB\Server\4.2\bin to the System Path. Then it asks to omit the full path to the the MongoDB binaries. That is where I think some information is missing. How are we supposed to omit the full path to the MongoDB binaries?

Currently I can get MongoDB to run mongod using:

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

For --dbpath="c:\data\db" you can replace "c:\data\db" with the path to your database.

I can also run mongo using:

"C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"

Another reason to it if you enabled any property in YAML file and it is not formatted properly. YAML looks for specific syntax like colon":"+space" ".

E.g.-

security:
    authorization: enabled
Related