Search code examples
mongodb

mongo command not recognized when trying to connect to a mongodb server


I am following the tutorials at docs.mongodb.org, I have completed the first tutorial which was to install mongodb on a Windows machine. I am now at the second stage which is getting started with mongodb development.

I am stuck at the first stage of this section which instructs me to type mongo into a system prompt. When I do this I simply get an error message saying the following:

'mongo' is not recognized as an internal or external command, operable program or batch file

I know this is probably something quite simple that I am doing wrong, does anyone have any ideas?


Solution

  • You need to run mongod first in one cmd window then open another and type mongo. Make sure you updated your Windows Path environment variable too so that you don't have to navigate to the directory you have all of the mongo binaries in to start the application. To update the Path variable:

    Go to Control Panel > System & Security > System > Advanced System Settings > Environment Variables > navigate to the Path variable hit Edit and add ;C:\mongodb to the Path (or whatever the directory name is where MongoDB is located (the semi-colon delimits each directory).