Adding MongoDB tools to system path in Windows
If you're trying to use the MongoDB tools on your Windows system you might have seen the below errors:
'mongod' is not recognized as an internal or external command, operable program or batch file.
or
'mongodump' is not recognized as an internal or external command, operable program or batch file.
or something similar.
This is because the tools are not in your system path.
In this blog post, I'll show you how to add the MongoDB tools to your system path so you can use them without any errors.
This will allow you to use the MongoDB tools from any location without having to specify the full path to the executable each time.
First, you'll need to find where the MongoDB tools are installed on your system.
The default location usually is C:\Program Files\MongoDB
And the core MongoDB components are usually located at C:\Program Files\MongoDB\Server\5.0\bin
Additional helpful tools are usually located at C:\Program Files\MongoDB\Tools\100\bin
Since both the above path are helpful in running MongoDB related commands, let us add both to our system path.
If you installed MongoDB in a different location or on a different version of MongoDB, you'll need to adjust the path accordingly.
Once you know where the MongoDB tools are located, you'll need to add that location to your system path.
Do the following to add the MongoDB tools to your system path:
- Press the Windows key on the keyboard, this will launch search.
- Now type "Edit system", and select the first option. (It will be "Edit the system environment variables")
- Click on the Environment Variables button.
- In the System Variables section, find the Path variable and click on it.
- Click the Edit button.
- Add the path to the MongoDB tools to the end of the existing path. Be sure to separate each entry with a semicolon.
- Click OK to save your changes.
Now you can use the MongoDB tools from any location without having to specify the full path.
You'll need to restart the command window/Terminal if it is open before trying the mongo tools command again.
You should now be able to run mongodb commands without any errors.
If you are interested, learn how to export data or migrate data from one server to another server.
Author: Anil Rao K