# Database Setup<no value>

## Why Use a Database

By default, the instance directory is in-memory. When the relay restarts, instances are lost. A MySQL or MariaDB database provides persistence across restarts.

## Connection String

```bash
DATABASE_URL=mysql://user:password@host:3306/relay
```

## How It Works

1. On startup, the relay connects to the database
2. All existing instances are loaded into the in-memory cache
3. Every mutation (add, update, remove, health check) is write-through — persisted immediately
4. If the database is unreachable at startup, the relay falls back to in-memory only

## Schema

The database schema is auto-created on first connection. No manual migration is needed.
