PATH Setup and Studio 3T
Configure the MongoDB PATH environment variable on Windows, macOS, and Linux so you can use mongo commands from any terminal. Also learn how to install and use Studio 3T (formerly MongoChef) — a powerful GUI for managing MongoDB databases.
After installing MongoDB, you may find that commands like mongosh or mongod aren't recognized in your terminal. This happens when MongoDB's binary directory isn't in your system's PATH. In this episode, we'll fix that and also set up Studio 3T — a professional GUI that makes working with MongoDB data much easier than the command line.
Setting Up PATH on Windows
On Windows, the MongoDB binaries are typically installed at C:\Program Files\MongoDB\Server\7.0\bin. To add this to your PATH:
- Open System Properties → Search "Environment Variables" in the Start menu
- Click "Environment Variables" button
- Under System Variables, find and select Path, then click Edit
- Click New and add:
C:\Program Files\MongoDB\Server\7.0\bin - Click OK on all dialogs
- Open a new Command Prompt or PowerShell and verify:
mongosh --version
mongod --version
Both commands should now return version information.
Setting Up PATH on macOS
If you installed via Homebrew, the PATH is usually configured automatically. If not, add MongoDB to your shell profile:
# For zsh (default on macOS)
echo 'export PATH="/usr/local/opt/mongodb-community@7.0/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# For Apple Silicon Macs
echo 'export PATH="/opt/homebrew/opt/mongodb-community@7.0/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Verify
mongosh --version
Setting Up PATH on Linux
If you installed via the package manager (apt/yum), the binaries are usually already in /usr/bin. For manual installations:
# Add to your .bashrc or .profile
echo 'export PATH="/usr/local/mongodb/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Verify
mongosh --version
mongod --version
MongoDB Compass — The Official GUI
MongoDB Compass is the free, official GUI from MongoDB Inc. It's included in the Windows installer and can be downloaded separately for macOS and Linux from mongodb.com/products/compass.
Key features of Compass:
- Visual query builder — Build queries by clicking, no syntax required
- Schema analysis — Automatically analyzes your document structure
- Performance insights — Real-time server stats and query performance
- Aggregation pipeline builder — Build complex aggregation pipelines step by step
- Index management — Create, view, and drop indexes visually
To connect Compass to your local MongoDB:
- Open MongoDB Compass
- The connection string should default to
mongodb://localhost:27017 - Click Connect
- You'll see all your databases listed in the left sidebar
Studio 3T — Professional MongoDB GUI
Studio 3T (formerly MongoChef) is a feature-rich, professional GUI for MongoDB. While it has a paid tier, the free version is extremely capable. Download it from studio3t.com/download.
Why Studio 3T?
- IntelliShell — Auto-complete for MongoDB queries, like an IDE for your shell
- Visual Query Builder — Drag-and-drop query building
- SQL Query — Write SQL queries against MongoDB (Studio 3T translates them)
- Export/Import — Export to JSON, CSV, SQL, and BSON formats
- Aggregation Editor — Build pipelines stage-by-stage with previews
- Data comparison — Compare collections across databases
- Connection management — Save and organize multiple database connections
Connecting Studio 3T to MongoDB
- Open Studio 3T
- Click Connect → New Connection
- Set the Server to
localhostand Port to27017 - Give the connection a name like "Local MongoDB"
- Click Test Connection to verify
- If successful, click Save and then Connect
Using Studio 3T
Once connected, you'll see a tree view of your databases on the left. Double-click any collection to view its documents. The interface has three view modes:
- Tree View — Expandable tree of nested document fields
- Table View — Spreadsheet-like grid, great for flat documents
- JSON View — Raw JSON output, useful for copying data
// Try this in Studio 3T's IntelliShell:
use testdb
db.users.insertOne({ name: "John", age: 30, city: "Mumbai" })
db.users.find()
MongoDB Shell (mongosh) Quick Reference
While GUIs are great, knowing the shell is essential. Here are the most-used commands:
// Show all databases
show dbs
// Switch to a database (creates it if doesn't exist)
use myDatabase
// Show collections in current database
show collections
// Get help
help
// Clear the screen
cls
// Exit the shell
exit
Configuring mongod
The MongoDB server (mongod) can be configured via command line flags or a configuration file:
# Start with custom data directory and port
mongod --dbpath /data/mydb --port 27018
# Start with a config file
mongod --config /etc/mongod.conf
A typical mongod.conf looks like:
# mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 127.0.0.1
What's Next
Your MongoDB environment is now fully set up — you can run commands from any terminal and visualize your data with a GUI. In the next episode, we'll start actually working with data by creating and dropping databases.