mongodb-atlas-checker
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMongoDB Atlas Checker
MongoDB Atlas 检查工具
Verify MongoDB Atlas setup and configuration. Identifies configuration issues, missing environment variables, incorrect connection strings, and ensures proper database setup.
验证MongoDB Atlas的安装与配置。识别配置问题、缺失的环境变量、错误的连接字符串,并确保数据库设置正确。
When to Use
使用场景
- Verifying MongoDB Atlas backend setup
- Checking connection string configuration
- Validating environment variable setup
- Troubleshooting database connection issues
- Auditing database setup before deployment
- 验证MongoDB Atlas后端配置
- 检查连接字符串配置
- 验证环境变量设置
- 排查数据库连接问题
- 部署前审计数据库设置
Quick Checklist
快速检查清单
1. Environment Variables
1. 环境变量
- exists (not hardcoded)
MONGODB_URI - Uses protocol (required for Atlas)
mongodb+srv:// - Includes database name
- Includes
retryWrites=true&w=majority - No credentials in
.env.example
- 存在(未硬编码)
MONGODB_URI - 使用协议(Atlas必填)
mongodb+srv:// - 包含数据库名称
- 包含参数
retryWrites=true&w=majority - 中不包含凭据
.env.example
2. Connection String Format
2. 连接字符串格式
mongodb+srv://<username>:<password>@<cluster-host>/<database>?retryWrites=true&w=majoritymongodb+srv://<username>:<password>@<cluster-host>/<database>?retryWrites=true&w=majority3. Driver Installation
3. 驱动安装
- or
mongoosepackage installedmongodb - In dependencies (not devDependencies)
- 已安装或
mongoose包mongodb - 位于dependencies中(而非devDependencies)
4. Connection Setup
4. 连接设置
- Singleton pattern (Next.js)
- (NestJS)
MongooseModule.forRoot() - Error handling implemented
- 单例模式(Next.js)
- 使用(NestJS)
MongooseModule.forRoot() - 已实现错误处理
5. Atlas Configuration
5. Atlas配置
- IP whitelist configured
- Database user exists with permissions
- SSL/TLS enabled (default with )
mongodb+srv://
- 已配置IP白名单
- 存在具备权限的数据库用户
- 已启用SSL/TLS(使用时默认启用)
mongodb+srv://
Common Issues
常见问题
| Issue | Solution |
|---|---|
Missing | Add to |
| Wrong protocol | Use |
| Multiple connections (Next.js) | Use singleton pattern |
| Connection timeout | Check IP whitelist in Atlas |
| Auth failed | Verify credentials, URL-encode special chars |
| 问题 | 解决方案 |
|---|---|
缺失 | 添加至 |
| 协议错误 | 使用 |
| 多连接问题(Next.js) | 使用单例模式 |
| 连接超时 | 检查Atlas中的IP白名单 |
| 认证失败 | 验证凭据,对特殊字符进行URL编码 |
Recommended Connection Options
推荐的连接选项
typescript
{
retryWrites: true,
w: 'majority',
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
bufferCommands: false,
}For detailed setup patterns, verification scripts, and complete examples:
references/full-guide.mdtypescript
{
retryWrites: true,
w: 'majority',
maxPoolSize: 10,
serverSelectionTimeoutMS: 5000,
bufferCommands: false,
}如需详细的设置模式、验证脚本及完整示例:
references/full-guide.md