The error message you’re seeing indicates that the ‘mongo’ command is not recognized by your command-line interface (CLI). This typically happens when the MongoDB executable is not in the system’s PATH (the list of directories where the system looks for executable files).
Here are a few steps you can take to resolve this issue:
- Check MongoDB Installation:
Ensure that MongoDB is installed on your system. You should have a ‘bin’ directory within the MongoDB installation directory, and the ‘mongo’ executable should be present in that directory. - Add MongoDB Bin Directory to PATH:
Add the ‘bin’ directory of your MongoDB installation to your system’s PATH. The exact steps for this depend on your operating system:
- On Windows: set PATH=%PATH%;C:\path\to\mongodb\bin Replace “C:\path\to\mongodb” with the actual path to your MongoDB installation.
- On Linux/macOS:
bash export PATH=$PATH:/path/to/mongodb/bin
You can add this line to your shell profile file (e.g., ~/.bashrc, ~/.bash_profile, or ~/.zshrc) to make the change permanent.
- Restart Your Terminal/Command Prompt:
After modifying the PATH, close and reopen your terminal or command prompt. This step is necessary for the changes to take effect. - Verify MongoDB Installation:
To check if MongoDB is now recognized, you can run:
mongo --version
This should display the version of MongoDB, confirming that the ‘mongo’ command is now recognized.
If you’re still encountering issues, double-check your MongoDB installation, and ensure that the ‘bin’ directory containing the ‘mongo’ executable is accessible in your system’s PATH.
Hello, I’m Hridhya Manoj. I’m passionate about technology and its ever-evolving landscape. With a deep love for writing and a curious mind, I enjoy translating complex concepts into understandable, engaging content. Let’s explore the world of tech together