Database Setup
Configure an external MySQL 8.0 instance for the Panel.
The Panel uses MySQL 8.0 via Drizzle ORM. The standard Docker Compose setup includes a co-located MySQL container, which is fine for most deployments. This guide covers using an external MySQL instance for scenarios that require dedicated database infrastructure.
Why External MySQL?
- Separate backup and maintenance schedules for the database
- Shared database host across multiple services
- Managed MySQL (e.g. PlanetScale, AWS RDS, DigitalOcean Managed Databases)
MySQL Requirements
| Requirement | Value |
|---|---|
| Version | MySQL 8.0+ |
| Character set | utf8mb4 |
| Collation | utf8mb4_unicode_ci |
| Time zone | UTC recommended |
Create the Database and User
Connect to MySQL as root and run:
CREATE DATABASE struxa
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'struxa'@'%' IDENTIFIED BY 'your-secure-password';
GRANT ALL PRIVILEGES ON struxa.* TO 'struxa'@'%';
FLUSH PRIVILEGES;Replace your-secure-password with a strong random password. Use openssl rand -hex 32 to generate one.
Configure the Panel
Set the DATABASE_URL environment variable in .env.prod (or your Panel's environment):
DATABASE_URL=mysql://struxa:your-secure-password@db.example.com:3306/struxaFormat: mysql://<user>:<password>@<host>:<port>/<database>
If using Docker Compose with an external database, remove the mysql service from your docker-compose.prod.yml and update the DATABASE_URL to point to the external host.
Firewall
Ensure the MySQL host accepts connections from the Panel container's IP or subnet. Avoid exposing port 3306 to the public internet - use a private network or a VPN between the Panel host and the database host.
Migrations
The Panel runs Drizzle migrations automatically on startup. No manual migration step is needed after initial setup. If you need to run migrations manually:
docker exec -it struxa-web bun run db:migrateManaged MySQL Services
Most managed MySQL services (PlanetScale, AWS RDS, DigitalOcean) work with the standard DATABASE_URL connection string. Ensure:
- SSL is enabled if required by the provider (append
?ssl=trueto the connection string) - The
utf8mb4character set is supported (it is on all modern MySQL 8.0 services)