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.

ℹ️ Note

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:admin permissions
  • Understanding of basic networking (CIDR, firewall rules)

1. Choose Your Database Engine

Select the database engine that best fits your application architecture.

1

Provision via CLI

Create a new PostgreSQL 16 instance with high availability enabled:

Terminal
cloudnexus db create --engine postgresql --version 16 --ha true --region us-east-1 --tier pro-4
--name app-primary-db
2

Configure Network Access

Restrict access to your VPC and trusted IP ranges:

Terminal
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
3

Connect to Your Instance

Use the generated connection string or connect directly via psql:

connection.env
DATABASE_URL=postgresql://admin:<password>@app-primary-db.db.cloudnexus.io:5432/main?sslmode=require
Terminal
psql --host app-primary-db.db.cloudnexus.io --port 5432 --username admin --dbname main
1

Provision MySQL 8.0

Deploy a clustered MySQL instance with automated failover:

Terminal
cloudnexus db create --engine mysql --version 8.0 --cluster true --region eu-west-2 --name user-service-db
2

Connection String

config.yaml
mysql://root:<password>@user-service-db.db.cloudnexus.io:3306/app_db?tls=verify-full&timezone=UTC
1

Deploy Replica Set

Terminal
cloudnexus db create --engine mongodb --version 7.0 --replica-set 3 --name analytics-db
2

Node.js Connection

src/db.js
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');
1

Deploy Cache Cluster

Terminal
cloudnexus db create --engine redis --version 7.2 --mode cluster --name session-cache
2

Python / Redis-py

app/cache.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

⚠️ Security Notice

Never hardcode credentials in your application. Use CloudNexus Secrets Manager or environment variables. Rotate passwords every 90 days.

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.