Skip to main content

Overview

The MySQL API allows you to create, manage, deploy, and monitor MySQL database instances. MySQL databases run as Docker containers with support for automated backups, external port configuration, and resource management.

Create MySQL Database

curl -X POST https://your-dokploy-instance.com/api/mysql.create \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-mysql",
    "appName": "prod-mysql",
    "databaseName": "myapp",
    "databaseUser": "admin",
    "databasePassword": "securePassword123!",
    "databaseRootPassword": "rootPassword456!",
    "dockerImage": "mysql:8",
    "environmentId": "env_123456",
    "description": "Production MySQL database"
  }'
{
  "mysqlId": "mysql_abc123",
  "name": "production-mysql",
  "appName": "prod-mysql",
  "databaseName": "myapp",
  "databaseUser": "admin",
  "dockerImage": "mysql:8",
  "applicationStatus": "idle",
  "createdAt": "2024-02-28T12:00:00Z"
}

Request Body

name
string
required
Display name for the MySQL database
appName
string
required
Unique application name used for Docker container naming (minimum 1 character)
databaseName
string
required
Name of the MySQL database to create
databaseUser
string
required
Username for database authentication
databasePassword
string
required
Password for the database user. Must match pattern: ^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$`
databaseRootPassword
string
required
Root password for MySQL. Must match pattern: ^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$`
environmentId
string
required
ID of the environment where the database will be deployed
dockerImage
string
default:"mysql:8"
Docker image to use for MySQL (e.g., mysql:8, mysql:9)
description
string
Optional description for the database instance
serverId
string
ID of the server where the database should be deployed (required in cloud environments)

Get MySQL Database

Retrieve details about a specific MySQL database instance.
curl -X GET "https://your-dokploy-instance.com/api/mysql.one?mysqlId=mysql_abc123" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Query Parameters

mysqlId
string
required
Unique identifier of the MySQL database

Deploy MySQL Database

Deploy or redeploy a MySQL database container.
curl -X POST https://your-dokploy-instance.com/api/mysql.deploy \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to deploy

Start MySQL Database

Start a stopped MySQL database container.
curl -X POST https://your-dokploy-instance.com/api/mysql.start \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123"
  }'

Stop MySQL Database

Stop a running MySQL database container.
curl -X POST https://your-dokploy-instance.com/api/mysql.stop \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123"
  }'

Reload MySQL Database

Reload (restart) a MySQL database container.
curl -X POST https://your-dokploy-instance.com/api/mysql.reload \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "appName": "prod-mysql"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to reload
appName
string
required
Application name of the MySQL database (minimum 1 character)

Update MySQL Database

Update MySQL database configuration, including credentials, resources, and Docker image.
curl -X POST https://your-dokploy-instance.com/api/mysql.update \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "name": "production-mysql-updated",
    "databasePassword": "newSecurePassword456!",
    "memoryLimit": "2g",
    "cpuLimit": "1.5"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to update (minimum 1 character)
name
string
Updated display name (minimum 1 character)
appName
string
Updated application name (minimum 1 character)
databaseName
string
Updated database name (minimum 1 character)
databaseUser
string
Updated database username (minimum 1 character)
databasePassword
string
Updated database password
databaseRootPassword
string
Updated root password
dockerImage
string
default:"mysql:8"
Updated Docker image version
memoryReservation
string
Memory reservation (e.g., “512m”, “1g”)
memoryLimit
string
Memory limit (e.g., “1g”, “2g”)
cpuReservation
string
CPU reservation (e.g., “0.5”, “1.0”)
cpuLimit
string
CPU limit (e.g., “1.0”, “2.0”)
command
string
Custom command to run in the container
args
array
Command line arguments for the MySQL server
externalPort
number
External port to expose MySQL

Save Environment Variables

Update environment variables for the MySQL database container.
curl -X POST https://your-dokploy-instance.com/api/mysql.saveEnvironment \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "env": "MYSQL_MAX_CONNECTIONS=200\nMYSQL_INNODB_BUFFER_POOL_SIZE=1G"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database
env
string
Environment variables in KEY=VALUE format, separated by newlines

Save External Port

Configure external port mapping for the MySQL database.
curl -X POST https://your-dokploy-instance.com/api/mysql.saveExternalPort \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "externalPort": 3306
  }'

Request Body

mysqlId
string
required
ID of the MySQL database
externalPort
number
required
Port number to expose MySQL externally. Set to null to remove external port mapping.

Change Status

Manually update the application status of a MySQL database.
curl -X POST https://your-dokploy-instance.com/api/mysql.changeStatus \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "applicationStatus": "done"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database
applicationStatus
string
required
New status. Options: idle, running, done, error

Move MySQL Database

Move a MySQL database to a different environment.
curl -X POST https://your-dokploy-instance.com/api/mysql.move \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123",
    "targetEnvironmentId": "env_789xyz"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to move
targetEnvironmentId
string
required
ID of the destination environment

Rebuild MySQL Database

Rebuild the MySQL database container from scratch.
curl -X POST https://your-dokploy-instance.com/api/mysql.rebuild \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to rebuild

Remove MySQL Database

Delete a MySQL database and all associated resources, including backups and scheduled jobs.
This action is irreversible. All database data and backups will be permanently deleted.
curl -X POST https://your-dokploy-instance.com/api/mysql.remove \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mysqlId": "mysql_abc123"
  }'

Request Body

mysqlId
string
required
ID of the MySQL database to remove

Backup Operations

For backup and restore operations, see the Backup API documentation.
  • Create automated backups: backup.create
  • Manual backup: backup.manualBackupMySql
  • Restore from backup: backup.restoreBackupWithLogs

Build docs developers (and LLMs) love