'.mongo' is not recognized as an internal or external command, operable program or batch file
I have installed mongo db. Then when i tried to execute .mongo or mongo in command prompt. It's showing this error:
.mongo' is not recognized as an internal or external command, operable program or batch file
I'm following some tutorial, So I'm not able to move further because i got stuck here. Help!
Solution 1:[1]
I think you might forgotten setting Environment variables for Mongo’s bin folder.Follow this,and try again.
Solution 2:[2]
This is an answer I posted on a similar question, for those that want a step-by-step guide:
You need to add Mongo's bin
folder to the "Path" Environment Variable
Here's how on Windows 10:
- Find Mongo's bin folder.
If you're not sure where it is, it's probably in C:\Program Files\MongoDB\Server\3.4\
3.4 was the latest stable version at the time, this will be different for you probably.
It should look like this:
Notice this is the path to mongo.exe and mongod.exe. Adding this folder to the Path variable is telling Windows to search in this folder for executables matching your command when you run something in cmd. The search starts with the current working dir, and if it doesn't find your exe, goes on to search all the paths in Path till it finds it or it doesn't and it gives you that error you saw.
Copy the path to the bin folder. It should be
C:\Program Files\MongoDB\Server\3.4\bin\
(Or whatever version you're using)Press win, type
env
, Windows will suggest "Edit the System Environment Variables", click that.
- On the Advanced tab, click "Environment Variables"
- Highlight the "Path" variable, click "Edit":
- This will bring up the "Edit environment variable" window, click "New"
- This will start a new line in the list of folders:
- Paste your path to the bin folder. Make sure it ends with a
\
like so:
Press "OK", "OK", "OK"
Open a new cmd window to work with the updated path variable.
Now you should be able to run mongod
and mongo
from anywhere in a command window.
Solution 3:[3]
Solution 4:[4]
Solution 5:[5]
for mongoDb v5.0 and latest use mongosh instead of mongo enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | xoxo |
Solution 2 | |
Solution 3 | Pasindu Perera |
Solution 4 | Azhar Uddin Sheikh |
Solution 5 | md nooruzzaman |