Database Provisioning
Learn how to provision databases instantly with StagDB.
Overview
StagDB provides instant database provisioning through Docker containerization. Each database instance runs in isolation with its own resources and configuration.
Supported Database Types
PostgreSQL
- Versions: 12, 13, 14, 15, 16
- Default port: 5432
- Extensions supported
MySQL
- Versions: 5.7, 8.0, 8.1
- Default port: 3306
- Full MySQL compatibility
MongoDB
- Versions: 5.0, 6.0, 7.0
- Default port: 27017
- Replica set support
Creating Databases
Via API
curl -X POST https://api.stagdb.com/v1/databases \
-H "Content-Type: application/json" \
-d '{
"name": "my-postgres-db",
"type": "postgresql",
"version": "15",
"config": {
"memory": "512m",
"storage": "1g"
}
}'
Via Web Dashboard
- Navigate to the dashboard
- Click "New Database"
- Select database type and version
- Configure resources
- Click "Create"
Configuration Options
Resource Limits
- Memory: 256m, 512m, 1g, 2g, 4g
- CPU: 0.5, 1, 2, 4 cores
- Storage: 1g, 5g, 10g, 25g, 50g
Environment Variables
- Custom environment variables
- Configuration overrides
- Initialization scripts
Database Management
Starting/Stopping
# Start database
curl -X POST https://api.stagdb.com/v1/databases/my-db/start
# Stop database
curl -X POST https://api.stagdb.com/v1/databases/my-db/stop
# Restart database
curl -X POST https://api.stagdb.com/v1/databases/my-db/restart
Monitoring
- Resource usage
- Connection metrics
- Performance statistics
- Log aggregation
Connection Information
After provisioning, you'll receive connection details:
{
"id": "db-12345",
"name": "my-postgres-db",
"type": "postgresql",
"status": "running",
"connection": {
"host": "stagdb.example.com",
"port": 5432,
"database": "postgres",
"username": "postgres",
"password": "generated-password"
},
"url": "postgresql://postgres:password@stagdb.example.com:5432/postgres"
}
Best Practices
Naming Conventions
- Use descriptive names:
user-service-postgres
- Include project/team:
team-alpha-mysql
- Add environment suffix:
api-postgres-dev
Resource Planning
- Start with minimal resources
- Monitor usage and scale up
- Use appropriate storage for data size
Security
- Rotate passwords regularly
- Use connection pooling
- Limit access by IP/network
Troubleshooting
Common Issues
Database Won't Start
- Check resource availability
- Verify configuration
- Review container logs
Connection Refused
- Confirm database is running
- Check firewall settings
- Verify connection details
Performance Issues
- Monitor resource usage
- Check for memory limits
- Review query performance