Skip to main content

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": "appuser",
    "databasePassword": "SecurePass123!",
    "databaseRootPassword": "RootPass456!",
    "dockerImage": "mysql:8",
    "environmentId": "env_123456",
    "description": "Main production MySQL database"
  }'
name
string
required
Display name for the MySQL database
appName
string
required
Unique application name used for Docker container identification
databaseName
string
required
Name of the database to create
databaseUser
string
required
Username for database access
databasePassword
string
required
Password for 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 this database will be deployed
dockerImage
string
default:"mysql:8"
Docker image to use for MySQL
description
string
Optional description of the database instance
serverId
string
Optional server ID for deployment on specific server
mysqlId
string
Unique identifier for the created MySQL instance
appName
string
Application name of the database
name
string
Display name of the database

Get MySQL Database

curl -X GET "https://your-dokploy-instance.com/api/mysql.one?mysqlId=mysql_123456" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
mysqlId
string
required
ID of the MySQL database to retrieve
mysqlId
string
Database identifier
name
string
Display name
appName
string
Application name
databaseName
string
Database name
databaseUser
string
Database username
dockerImage
string
MySQL Docker image
applicationStatus
string
Current status: idle, running, done, or error
externalPort
number
External port for database access (if configured)

Deploy MySQL

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_123456"
  }'
mysqlId
string
required
ID of the MySQL database to deploy

Start MySQL

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_123456"
  }'
mysqlId
string
required
ID of the MySQL database to start

Stop MySQL

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_123456"
  }'
mysqlId
string
required
ID of the MySQL database to stop

Update MySQL

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_123456",
    "name": "Updated MySQL Database",
    "description": "Updated description",
    "memoryLimit": "2g",
    "memoryReservation": "1g",
    "cpuLimit": "1",
    "cpuReservation": "0.5"
  }'
mysqlId
string
required
ID of the MySQL database to update
name
string
New display name
appName
string
New application name
description
string
New description
databaseName
string
Database name
databaseUser
string
Database username
databasePassword
string
User password
databaseRootPassword
string
Root password
memoryLimit
string
Maximum memory (e.g., “2g”, “512m”)
memoryReservation
string
Guaranteed memory allocation
cpuLimit
string
Maximum CPU cores
cpuReservation
string
Guaranteed CPU allocation
command
string
Custom command override
args
array
Command arguments

Save External Port

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_123456",
    "externalPort": 3306
  }'
mysqlId
string
required
ID of the MySQL database
externalPort
number
Port number for external access. Set to null to remove external port.

Save Environment Variables

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_123456",
    "env": "MYSQL_MAX_CONNECTIONS=200\nMYSQL_INNODB_BUFFER_POOL_SIZE=256M"
  }'
mysqlId
string
required
ID of the MySQL database
env
string
Environment variables in KEY=VALUE format, separated by newlines

Reload MySQL

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_123456",
    "appName": "prod-mysql"
  }'
mysqlId
string
required
ID of the MySQL database
appName
string
required
Application name of the database

Rebuild MySQL

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_123456"
  }'
mysqlId
string
required
ID of the MySQL database to rebuild

Remove MySQL

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_123456"
  }'
mysqlId
string
required
ID of the MySQL database to remove

Connection String Format

mysql://[databaseUser]:[databasePassword]@[appName]:3306/[databaseName]
Example:
mysql://appuser:SecurePass123!@prod-mysql:3306/myapp
For external connections:
mysql://appuser:[email protected]:3306/myapp

Mount Path

MySQL data is stored at /var/lib/mysql inside the container.

Build docs developers (and LLMs) love