Before you can practice queries, you need a running MongoDB server. In this lesson you will learn two ways to get one: installing MongoDB Community Server on your own machine, and creating a free cloud database with MongoDB Atlas. You will also meet mongosh, the modern MongoDB shell that we will use throughout this CodeYourCraft tutorial series.
MongoDB Community Server is free and runs on Windows, macOS, and Linux.
Windows: download the MSI installer from the official MongoDB download center, choose the Complete setup, and let the installer register MongoDB as a Windows service so it starts automatically. The installer can also add MongoDB Compass, the official GUI.
macOS: the easiest path is Homebrew:
brew tap mongodb/brew
brew install mongodb-community@7.0
brew services start mongodb-community@7.0Linux (Ubuntu): add the official MongoDB APT repository, then install and start the service:
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongodBy default the server (the mongod process) listens on port 27017 and stores data in a data directory it manages for you.
MongoDB Atlas is the official database-as-a-service. The free M0 tier gives you a 512 MB cluster that is perfect for learning, with nothing to install and automatic security defaults. To set it up:
A typical Atlas connection string looks like this:
mongodb+srv://appuser:<password>@cluster0.abc12.mongodb.net/shopKeep this string secret, because anyone who has it can reach your database. In real projects it belongs in an environment variable, never in source code.
mongosh is the interactive MongoDB shell. It ships with recent server installers and can also be installed on its own. Connecting is one command:
# Local server
mongosh
# Atlas cluster
mongosh "mongodb+srv://cluster0.abc12.mongodb.net/shop" --username appuserOnce connected, try a few commands to prove everything works:
db.runCommand({ ping: 1 }) // { ok: 1 }
show dbs // list databases
db.hello().me // which server you are talking tomongosh is a full JavaScript environment, so you can declare variables, write loops, and call every database command from one prompt.
If you prefer a graphical interface, MongoDB Compass lets you browse collections, run queries visually, analyze schemas, and inspect index usage. Compass is excellent for exploring unfamiliar data, but learning the shell first will make you faster and will translate directly into driver code later in the series.
For this course either works. A local install keeps everything offline and under your control, which is handy on flights or restricted networks. Atlas mirrors how most teams run MongoDB in production, gives you backups and monitoring out of the box, and lets you practice from any machine. Many developers use both: Atlas for shared environments and a local server for quick experiments.
Next up, we will create our first database and collections, and learn exactly how MongoDB organizes documents.