Setting Up a Managed Database
Provision, configure, and securely connect to your CloudNexus managed database instance in minutes. This guide covers PostgreSQL, MySQL, MongoDB, and Redis.
All managed databases include automated backups, point-in-time recovery, and SSL/TLS encryption by default. No configuration required.
📋 Prerequisites
- Active CloudNexus account with billing enabled
- CLI tool installed (v2.4.0 or higher)
- API key with
db:adminpermissions - Understanding of basic networking (CIDR, firewall rules)
1. Choose Your Database Engine
Select the database engine that best fits your application architecture.
Provision via CLI
Create a new PostgreSQL 16 instance with high availability enabled:
cloudnexus db create --engine postgresql --version 16 --ha true --region us-east-1 --tier pro-4
--name app-primary-db
Configure Network Access
Restrict access to your VPC and trusted IP ranges:
cloudnexus db firewall add app-primary-db --source 10.0.0.0/8 --source 203.0.113.45
# Verify rules
cloudnexus db firewall list app-primary-db
Connect to Your Instance
Use the generated connection string or connect directly via psql:
DATABASE_URL=postgresql://admin:<password>@app-primary-db.db.cloudnexus.io:5432/main?sslmode=require
psql --host app-primary-db.db.cloudnexus.io --port 5432 --username admin --dbname main
Provision MySQL 8.0
Deploy a clustered MySQL instance with automated failover:
cloudnexus db create --engine mysql --version 8.0 --cluster true --region eu-west-2 --name user-service-db
Connection String
mysql://root:<password>@user-service-db.db.cloudnexus.io:3306/app_db?tls=verify-full&timezone=UTC
Deploy Replica Set
cloudnexus db create --engine mongodb --version 7.0 --replica-set 3 --name analytics-db
Node.js Connection
import { MongoClient } from 'mongodb';
const client = new MongoClient(
'mongodb+srv://admin:<password>@analytics-db.db.cloudnexus.io/?retryWrites=true&w=majority'
);
await client.connect();
const db = client.db('analytics');
Deploy Cache Cluster
cloudnexus db create --engine redis --version 7.2 --mode cluster --name session-cache
Python / Redis-py
import redis
r = redis.Redis(
host='session-cache.db.cloudnexus.io',
port=6379,
password='<your-password>',
ssl=True,
ssl_cert_reqs=None
)
2. Security & Best Practices
Never hardcode credentials in your application. Use CloudNexus Secrets Manager or environment variables. Rotate passwords every 90 days.
- Enable
mTLSfor internal service-to-service communication - Use read replicas for analytics and reporting workloads
- Set connection pooling limits to prevent resource exhaustion
- Enable query logging only during debugging (performance impact)
3. Troubleshooting
Connection timeout / ECONNREFUSED
Verify your IP is in the allowed firewall list. Check that the database instance is in running status using cloudnexus db status <name>.
SSL/TLS handshake errors
CloudNexus requires SSL mode require or verify-full. Ensure your client certificate bundle is up to date: cloudnexus db certs download.
High memory usage / OOM kills
Review query execution plans. Enable connection pooling (PgBouncer/ProxySQL) and consider scaling to a higher tier via the dashboard or CLI.