Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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!

like image 293
Sherlock Avatar asked Jul 07 '18 16:07

Sherlock


People also ask

Why mongo exe not found?

After version 6.0. 0 mongo.exe does not get installed to your bin folder so you have to manually install the new MongoDB shell which is called mongosh then you have to add its path to your system variables and then run mongosh --version to see if it got installed.

Why mongo is not working in cmd?

mongo is not recognized as an internal or external command This error usually occurs because the system can not find the executable that you are asking to launch so to launch the file you have to provide the full path and after that, it will run without any issues.


2 Answers

I think you might forgotten setting Environment variables for Mongo’s bin folder.Follow this,and try again.

Set Environment variables for mongo db's bin folder path

like image 105
xoxo Avatar answered Sep 19 '22 00:09

xoxo


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:

  1. 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:

This is what Mongo's bin folder looked like for version 3.4, the important thing is it's whatever folder contains mongod.exe. 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.

  1. Copy the path to the bin folder. It should be C:\Program Files\MongoDB\Server\3.4\bin\ (Or whatever version you're using)

  2. Press win, type env, Windows will suggest "Edit the System Environment Variables", click that.

How to find the system environment variables.

  1. On the Advanced tab, click "Environment Variables"

The Advanced tab in System Properties contains the Environment Variables.

  1. Highlight the "Path" variable, click "Edit":

You want to edit the Path variable to add Mongo's bin folder to it.

  1. This will bring up the "Edit environment variable" window, click "New"

Add a new folder to the Path variable

  1. This will start a new line in the list of folders:

A new line in the Path variable.

  1. Paste your path to the bin folder. Make sure it ends with a \ like so:

Paste the location of the bin folder.

  1. Press "OK", "OK", "OK"

Now you should be able to run mongod and mongo from anywhere in a command window.

like image 31
Travis Heeter Avatar answered Sep 18 '22 00:09

Travis Heeter