MongoDB Atlas Management from CLI
Manage MongoDB Atlas clusters, databases, and users from the command line using the Atlas CLI for automated cloud database operations.
Prerequisites
- -MongoDB Atlas account (free tier available)
- -Atlas CLI installed (brew install mongodb-atlas-cli or equivalent)
Steps
Authenticate with Atlas
Log in to your Atlas account from the CLI.
This opens a browser for OAuth authentication. For CI/CD, use API keys: atlas config init --apiKey and --privateKey.
List your Atlas projects
View all projects (organizations) in your Atlas account.
Create a free-tier cluster
Deploy a new M0 (free tier) cluster in your project.
M0 is free forever with 512MB storage. Use M10+ for production workloads.
Check cluster status
View the status and connection details of your clusters.
Create a database user
Add a user with readWrite access for application connections.
Get the connection string
Retrieve the connection string to use in your application.
Use the 'mongodb+srv://' connection string format. It handles DNS-based service discovery and replica set routing automatically.
Full Script
FAQ
Discussion
Loading comments...