System Env Path Setting
System Path Setting
To set the system environment variable PATH for MongoDB Shell (mongosh), follow these steps based on your operating system:
Windows
Find the mongosh Path
Default location:
C:\Program Files\MongoDB\mongosh\bin
Set PATH Variable
Open Start Menu and search for "Environment Variables"
Click "Edit the system environment variables"
In the System Properties window, click "Environment Variables"
Under System variables, find Path and click Edit
Click New, then paste:
C:\Program Files\MongoDB\mongosh\bin
Click OK to save changes.
Verify
Open Command Prompt (cmd) or Windows PowerShell terminal and type:
mongosh
If it launches, the configuration is successful.
MacOS & Linux
Find the mongosh Path
Default Homebrew install path:
/opt/homebrew/bin/mongosh
Set PATH Variable
Open Terminal and run:
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.bashrc
or for Zsh (default shell in macOS newer versions):
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
Apply Changes
source ~/.bashrc # For Bash source ~/.zshrc # For Zsh
Verify
mongosh
If it starts successfully, the setup is complete.
This ensures you can use mongosh from any terminal or command prompt session without specifying the full path. 🚀
Last updated