Skip to content

MySQL / MariaDB

Overview

StarkOne provides full MySQL/MariaDB management: database creation, user management, import/export, phpMyAdmin integration, performance tuning, and replication.

All database endpoints require at minimum websites_management. Admin-level MySQL operations (tuner, replication, restart) require administrative_operations.

Database Operations

List Databases for a Website

GET /api/webapps/:id/databases

Create a Database

POST /api/databases
{
  "username": "example",
  "db_name": "example_wp",
  "db_user": "example_wpuser",
  "db_password": "secret"
}

Delete a Database

DELETE /api/databases/:id

Duplicate a Database

POST /api/databases/:id/duplicate
{
  "new_name": "example_wp_backup"
}

Import a Database

POST /api/databases/:id/import
Content-Type: multipart/form-data

# Form field: file (SQL dump)

Export a Database

POST /api/databases/:id/export

# Then download:
GET /api/databases/:id/download

Database Users

Create User

POST /api/databases/:id/users
{
  "username": "extra_user",
  "password": "secret",
  "host": "localhost"
}

Reset User Password

POST /api/databases/:id/users/:username/reset-password
{ "password": "new_secret" }

Delete User

DELETE /api/databases/:id/users/:username

MySQL Dashboard

Global MySQL admin panel - requires administrative_operations:

# Service status
GET /api/mysql/status

# Running processes
GET /api/mysql/processes

# Kill a process
POST /api/mysql/processes/:id/kill

# Kill all user processes
POST /api/mysql/processes/kill-all

# Slow query log
GET /api/mysql/slow-log

# Real-time monitor stats
GET /api/mysql/monitor-stats

# Restart / stop / (re)install
POST /api/mysql/restart
POST /api/mysql/stop
POST /api/mysql/install

Remote Access

POST /api/settings/mysql/remote
{ "enabled": true, "allowed_ip": "203.0.113.1" }

Port

POST /api/settings/mysql/port
{ "port": 3306 }

Max Connections

POST /api/settings/mysql/max-connections
{ "max_connections": 500 }

Read-Only Mode

POST /api/settings/mysql/read-only
{ "enabled": true }

phpMyAdmin

StarkOne can install phpMyAdmin and provide single-click login:

# Status
GET /api/mysql/phpmyadmin

# Install
POST /api/mysql/phpmyadmin/install

# Update
POST /api/mysql/phpmyadmin/update

# Get auto-login URL
POST /api/mysql/phpmyadmin/login

MySQL Optimizer (Tuner)

Runs MySQLTuner to analyse and apply performance recommendations:

# Run tuner analysis
GET /api/mysql/tuner

# Install MySQLTuner
POST /api/mysql/tuner/install

# Apply recommended settings
POST /api/mysql/tuner/apply
{ "recommendations": ["max_connections=300", "innodb_buffer_pool_size=512M"] }

MySQL Replication

StarkOne supports master-slave MySQL replication setup via the panel.

# Get replication status
GET /api/mysql/replication

# Initialise replication (configure master binlog)
POST /api/mysql/replication/init

# Connect slave to master
POST /api/mysql/replication/connect
{
  "master_host": "10.0.0.1",
  "master_user": "replication",
  "master_password": "secret"
}

# Start slave replication
POST /api/mysql/replication/start

# Initial data sync (copies all DBs from master to slave)
POST /api/mysql/replication/sync

# SSE stream for sync progress
GET /api/mysql/replication/sync-stream

# List replication slaves
GET /api/mysql/replication/slaves

# Add slave
POST /api/mysql/replication/slaves
{ "host": "10.0.0.2", "port": 3306 }

# Remove slave
DELETE /api/mysql/replication/slaves/:id

# Remove replication configuration
DELETE /api/mysql/replication

# Skip replication error
POST /api/settings/mysql/replication/skip-error

# Restart replication
POST /api/settings/mysql/replication/restart

# Set slave skip errors
POST /api/settings/mysql/slave-skip-errors
{ "errors": "1062,1032" }

Replication Endpoints (Called by Slaves)

Several replication endpoints are public (no JWT) but protected by a shared token - they're called server-to-server by slave nodes:

  • POST /api/mysql/replication/accept
  • POST /api/mysql/replication/setup-master
  • POST /api/mysql/replication/dump
  • POST /api/mysql/replication/position

Sync Users for HA

When using ProxySQL for high-availability, sync MySQL users between servers:

POST /api/mysql/sync-users-ha

MySQL Host

GET /api/databases/mysql-host

Returns the MySQL host used by the panel (usually localhost).