# Databases Overview

DanubeData provides fully managed database instances with MySQL, PostgreSQL, and MariaDB support.

## What are Database Instances?

Database instances are managed database servers that provide:

- **Automated Setup**: Deploy in minutes
- **Automated Backups**: Daily backups (managed PostgreSQL adds 30-day continuous backups)
- **High Availability**: Read replicas and automatic failover
- **Storage Autoscaling**: Optional automatic disk growth before you run out of space
- **In-Place Version Upgrades**: Move MySQL and PostgreSQL to a newer engine version without recreating
- **SQL Studio**: An in-browser data studio included free with every PostgreSQL instance
- **Monitoring & Alerts**: Real-time metrics with configurable metric alerts and health monitoring
- **Security**: Firewall integration and encrypted (TLS/SSL) connections

## Supported Database Engines

### MySQL
- Versions: 8.0, 8.4, 9.0, 9.1
- Use cases: Web applications, e-commerce, CMS
- Features: InnoDB storage, full-text search, JSON support

### PostgreSQL
- Versions: 15, 16, 17, 18
- Use cases: Analytics, complex queries, GIS applications
- Features: JSONB, full-text search, one-click PostGIS, connection pooler, SQL Studio

### MariaDB
- Versions: 10.11, 11.4, 11.6
- Use cases: Drop-in MySQL replacement
- Features: Improved performance, better replication

## Key Features

### 📊 Performance Monitoring
- Real-time CPU, memory, and disk metrics
- Query performance tracking
- Connection monitoring
- Slow query logs

### 🔒 Security
- Firewall protection
- Private networking
- Encrypted connections (TLS/SSL)
- Encrypted backups

### 💾 Automated Backups
- Daily automated backups with 3-day retention
- Managed PostgreSQL adds 30-day continuous backups
- Point-in-time recovery
- Manual snapshots

### 📈 Scalability
- Read replicas for scaling reads
- Vertical scaling (resize instances)
- Storage autoscaling (optional automatic disk growth)
- In-place engine version upgrades (MySQL, PostgreSQL)
- Connection pooling (built-in pgBouncer proxy for PostgreSQL)

### ⚙️ Customization
- Custom parameter groups
- Version selection
- Storage configuration

## Getting Started

### Create a Database

1. Navigate to **Databases** in the main menu
2. Click **Create Database Instance**
3. Select your database engine (MySQL, PostgreSQL, or MariaDB)
4. Choose a version
5. Select a resource profile
6. Configure networking and security
7. Click **Create Database**

Your database will be ready in 2-3 minutes!

### Connect to Your Database

Once your database is running, you'll receive:
- **Hostname**: The connection endpoint
- **Port**: 3306 for MySQL/MariaDB, 5432 for PostgreSQL on the private network.
  With public access enabled, the public hostname listens on its own port instead
  — see below
- **Database Name**: The ready-to-use database we created for you, shown right in the credentials card
- **Username**: Database username
- **Password**: Secure password (shown once)

**Example Connection String:**
```
mysql -h your-db-hostname -P 3306 -u admin -p
```

By default a database is reachable only from within your private network. To connect from outside DanubeData, enable public access (DNS) on the instance — its firewall opens automatically so external clients can connect right away, and closes again the moment you turn public access back off.

**The public endpoint uses a different port than the private one.** Public
traffic arrives through a shared load balancer, where your instance gets its own
dedicated port — not 3306 or 5432. Those engine ports stay correct for
private-network connections. Always copy the port shown next to the endpoint in
the dashboard, or read it from the API:

| Where you connect from | Hostname | Port |
|---|---|---|
| Private network (VPS, other DanubeData resources) | short in-cluster name | `port` (3306 / 5432) |
| Public internet (public access enabled) | public DNS hostname | `dns_port` |

DNS records cannot carry a port number, so resolving the hostname tells you
nothing about which port to use. API clients should read `connection_host` and
`connection_port` — they always resolve to the correct pair:

```bash
curl -H "Authorization: Bearer $DANUBEDATA_TOKEN" \
  https://api.danubedata.ro/api/v1/database/$DATABASE_ID/credentials
```

```json
{
  "host": "postgresql-orders.acme.danubedata.ro",
  "port": 5438,
  "username": "pguser",
  "database": "orders",
  "password": "...",
  "connection_info": "postgresql://pguser:...@postgresql-orders.acme.danubedata.ro:5438/orders"
}
```

The read-replica ("reader") endpoint is private-network only and always uses the
engine port, even when public access is enabled.

## Resource Profiles

| Profile | vCPU | RAM | Storage | Monthly |
|---------|------|-----|---------|---------|
| Small | 2 | 4 GB | 50 GB | €19.99 |
| Medium | 4 | 8 GB | 100 GB | €39.99 |
| Large | 8 | 16 GB | 200 GB | €79.99 |

## Read Replicas

Scale read operations by creating replicas:

1. Go to your database instance page
2. Click **Replicas** tab
3. Click **Add Replica**
4. Select a node and resource profile
5. Click **Create Replica**

### Benefits
- Offload read queries from primary
- Runs on a separate host in the same datacenter
- Automatic synchronization
- Promote to primary if needed

## Backups & Recovery

### Automated Backups
- Performed daily automatically
- 3-day retention
- No performance impact
- Stored securely

### Manual Snapshots
1. Go to your database page
2. Click **Snapshots** tab
3. Click **Create Snapshot**
4. Enter a name
5. Click **Create**

### Restore from Backup
1. Navigate to **Snapshots**
2. Click **Restore** on a snapshot
3. Choose to restore to existing or new instance

## Parameter Groups

Customize database configuration:

1. Navigate to **Parameter Groups**
2. Click **Create Parameter Group**
3. Select database engine and version
4. Configure parameters
5. Attach to your database instance

Default (system) parameter groups are version-scoped — the dropdown filters to groups that match your instance's engine version. Custom parameter groups remain compatible across versions. See [Parameter Groups](https://docs.danubedata.ro/databases-parameters) for the full reference.

## Storage Autoscaling

Turn on autoscaling for any managed database and its storage grows automatically before it fills up — so a full disk never takes your database offline.

- **Enable anytime**: Switch it on when creating a database, or later from the instance's edit page. It's **off by default** — nothing changes unless you opt in.
- **Your thresholds**: Set the usage level that triggers growth (default **80% used**) and how much storage to add each time (default **80 GiB**), per instance.
- **Controlled growth**: A cooldown between scale-events keeps storage from growing too aggressively, and a **maximum size cap** (within your plan and account limits) keeps it bounded — set a lower cap yourself for tighter control.
- **Transparent cost**: The instance page shows autoscaling status and the projected monthly cost of the next scale-up, billed at the standard per-GiB storage rate.

> Storage grows but never shrinks automatically. Pick a maximum size that fits your budget.

## Version Upgrades

Move a **MySQL** or **PostgreSQL** instance to a newer engine version in place — no need to recreate it or dump and reload your data.

1. Open the **Updates** tab on your database instance
2. Pick an available target version
3. Start the upgrade — a snapshot is taken automatically first, so you can restore if anything looks wrong afterward
4. Track progress live on the instance page; the instance shows an **Updating** status across the dashboard while the upgrade runs

Available today for MySQL and PostgreSQL, and upgrades follow supported version paths (for example, MySQL 8.0 → 8.4 → 9.0/9.1). Take a manual snapshot first if you want an extra restore point.

## SQL Studio

Every managed **PostgreSQL** instance includes [SQL Studio](https://docs.danubedata.ro/databases-sql-studio) — a full database GUI in your browser, with no client to install and no credentials to copy:

- Browse schemas, tables, and rows with sorting, filters, and pagination
- Edit data with staged, transactional commits (applied all-or-nothing)
- Run ad-hoc SQL with a read-only safe mode, saved snippets, query history, and CSV/JSON export
- Create, rename, duplicate, and drop tables; import from CSV; visualize relationships with ER diagrams

SQL Studio is included free with every PostgreSQL plan. It is not available for MySQL or MariaDB. See the [SQL Studio guide](https://docs.danubedata.ro/databases-sql-studio) for details.

## High Availability

For managed **PostgreSQL**, enable the **High availability** setting to run your instance with a synchronized standby and **automatic failover** — if the primary becomes unhealthy, a standby is promoted for you, with near-zero downtime during planned changes. Replication, standby provisioning, and failover are all handled by the platform.

All engines also support [read replicas](https://docs.danubedata.ro/databases-replicas), which add read capacity through a load-balanced reader endpoint and can be promoted to primary for resilience.

## Cloning

Need a copy of a database — for staging, testing, or a migration dry-run? Clone any managed database into a brand-new instance from the dashboard. The clone is an independent instance with its own connection details and password; changes to it never affect the original.

## Monitoring

Track database performance:

### Key Metrics
- **CPU Usage**: Monitor compute resources
- **Memory Usage**: Track RAM and buffer pool
- **Connections**: Active and max connections
- **Queries per Second**: Throughput
- **Disk I/O**: Read/write operations
- **Replication Lag**: For replicas

### Metric Alerts
Set your own thresholds on a database and get an email when they're breached — and again when they resolve:
- High CPU usage
- Memory exhaustion
- Disk usage
Create and manage these from the **Alerts** section; see [Alerting](https://docs.danubedata.ro/monitoring-alerting).

### Health Monitoring
We watch the health of your database around the clock. If it runs into trouble — a crash loop, out-of-memory, image-pull failure, and more — your whole team is notified by email and in the Notification Center, and a warning banner appears on the instance page. Alerts clear themselves automatically once the database recovers. No setup required.

### Log Explorer
Search, filter, and live-tail your database logs from the **Logs** page under **Observability** — by level, keyword, or regex pattern — or jump straight into a database's logs from its own instance page. See [Logs](https://docs.danubedata.ro/monitoring-logs).

## Best Practices

### Performance
1. Use appropriate indexes
2. Optimize queries
3. Configure buffer pool size
4. Use connection pooling
5. Monitor slow queries

### Security
1. Use strong passwords
2. Enable firewalls
3. Use private networks
4. Restrict access by IP
5. Enable SSL/TLS

### Reliability
1. Enable automated backups
2. Take manual snapshots before major changes
3. Test restore procedures
4. Monitor replication lag
5. Set up read replicas

### Cost Optimization
1. Right-size your instance
2. Stop idle databases to pause hourly compute billing
3. Clean up old data
4. Archive historical data
5. Delete unused snapshots

## Troubleshooting

### High CPU Usage
1. Identify slow queries
2. Add missing indexes
3. Optimize queries
4. Consider upgrading instance

### Connection Errors
1. Check firewall rules
2. Verify connection details
3. Check max connections setting
4. Review connection pool settings

### Replication Lag
1. Check network connectivity
2. Review primary load
3. Increase replica resources
4. Optimize queries on primary

## Next Steps

- [MySQL Documentation](https://docs.danubedata.ro/databases-mysql)
- [PostgreSQL Documentation](https://docs.danubedata.ro/databases-postgresql)
- [MariaDB Documentation](https://docs.danubedata.ro/databases-mariadb)
- [Database Replicas](https://docs.danubedata.ro/databases-replicas)
- [Parameter Groups](https://docs.danubedata.ro/databases-parameters)

Need help? Contact our support team through the dashboard.

