Templates

MySQL

Deploy MySQL 8 with persistent storage — relational database with auto-generated credentials

Ink deploys MySQL 8 as a container service with a persistent volume. Your agent provisions the database using a template — credentials are auto-generated and returned immediately.

Deploying

Your agent uses the template_deploy MCP tool:

Tool Call
(
  : "mysql",
  : "my-db"
)
{
  "services": [object Object],
  "outputs": [object Object]
}

Or via the CLI:

ink template deploy mysql --name my-db

Auto-generated credentials

VariableValue
MYSQL_ROOT_PASSWORDAuto-generated at deploy time
MYSQL_DATABASErailway
DATABASE_URLFull connection string with generated credentials

Passwords are randomly generated. The agent receives them as outputs — no manual password management required.

Persistent storage

A persistent volume is attached at /var/lib/mysql (1 Gi default). Data survives container restarts and redeployments.

Connecting

After deployment, template_deploy returns a DATABASE_URL in the format:

mysql://root:pass@hostname:3306/dbname

The internal URL (my-db:3306) is used for service-to-service communication within the same project. Any sibling service can connect by hostname — no external networking required.

Client libraries

Node.js

npm install mysql2
import mysql from 'mysql2/promise';

const connection = await mysql.createConnection(process.env.DATABASE_URL);
const [rows] = await connection.execute('SELECT * FROM users');

Python

pip install mysql-connector-python
import os
import mysql.connector

conn = mysql.connector.connect(
    host="my-db",
    port=3306,
    user="root",
    password=os.environ["MYSQL_ROOT_PASSWORD"],
    database="railway"
)
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")

Specs

PropertyValue
EngineMySQL 8
Imagemysql:8
Port3306
Volume/var/lib/mysql
Default Memory512Mi
Default vCPU0.5

On this page