Skip to main content
MariaDB is a community-developed, commercially supported fork of MySQL. It’s designed to be highly compatible with MySQL while offering additional features and performance improvements.

Creating a MariaDB Database

To create a MariaDB database in Dokploy:
  1. Navigate to your project
  2. Select the environment
  3. Click “Add Service” and select “MariaDB”
  4. Configure the database settings

Basic Configuration

  • Name - A friendly name for your database
  • App Name - The Docker service name (used for internal DNS)
  • Description - Optional description
  • Docker Image - Default: mariadb:latest (recommended: mariadb:11 or mariadb:10.11)

Database Credentials

  • Database Name - Name of the database to create
  • Database User - Username for database access
  • Database Password - Password for the user
  • Root Password - Password for the root user
These credentials are automatically configured via environment variables:
  • MARIADB_DATABASE
  • MARIADB_USER
  • MARIADB_PASSWORD
  • MARIADB_ROOT_PASSWORD

Advanced Settings

  • External Port - Optional port to expose MariaDB externally (default internal port: 3306)
  • Command - Override the default container command
  • Args - Additional arguments to pass to MariaDB
  • Environment Variables - Additional custom environment variables

Connection Strings

Internal Connection (from other services)

When connecting from applications within the same Docker network:
mysql://[user]:[password]@[appName]:3306/[database]
Example:
mysql://myuser:mypassword@my-mariadb:3306/myapp
MariaDB uses the same protocol and port as MySQL, making it a drop-in replacement in most cases.

External Connection

If you’ve configured an external port (e.g., 3307):
mysql://[user]:[password]@[host]:[externalPort]/[database]

Connection String Formats

mysql://username:password@hostname:3306/database

Environment Variables

MariaDB containers support these environment variables:
VariableDescriptionRequired
MARIADB_ROOT_PASSWORDRoot user passwordYes
MARIADB_DATABASEDatabase to create on startupYes
MARIADB_USERUser to createYes
MARIADB_PASSWORDPassword for MARIADB_USERYes
MARIADB_ALLOW_EMPTY_PASSWORDAllow root with empty passwordNo
MARIADB_RANDOM_ROOT_PASSWORDGenerate random root passwordNo
MARIADB_AUTO_UPGRADEAuto upgrade on version changeNo
Dokploy automatically sets the required variables based on your configuration.

Data Persistence

MariaDB data is stored in a Docker volume mounted at:
  • Mount Path: /var/lib/mysql
  • Volume Name: {appName}-data
The volume persists even when the container is stopped or removed.

Resource Configuration

Configure resource limits for your MariaDB instance:
Memory Limit: 2GB        # Maximum memory
Memory Reservation: 1GB   # Guaranteed memory
CPU Limit: 2.0           # Maximum CPU cores
CPU Reservation: 0.5     # Guaranteed CPU cores
MariaDB is generally more memory-efficient than MySQL. For production workloads, start with 1-2GB of memory and adjust based on usage.

Operations

Starting the Database

Click the “Start” button in the Dokploy UI or use the API:
POST /api/mariadb/start
{
  "mariadbId": "your-mariadb-id"
}

Stopping the Database

Click the “Stop” button or use the API:
POST /api/mariadb/stop
{
  "mariadbId": "your-mariadb-id"
}

Reloading the Database

Reload applies configuration changes by stopping and starting the service:
POST /api/mariadb/reload
{
  "mariadbId": "your-mariadb-id"
}

Rebuilding the Database

Rebuilding will delete all data. Make sure to backup first!
POST /api/mariadb/rebuild
{
  "mariadbId": "your-mariadb-id"
}

Accessing MariaDB CLI

To access the MariaDB CLI in the running container:
docker exec -it $(docker ps -qf "name=my-mariadb") mariadb -u myuser -p myapp
Or use the legacy MySQL command:
docker exec -it $(docker ps -qf "name=my-mariadb") mysql -u myuser -p myapp

Common MariaDB Commands

MariaDB is MySQL-compatible, so most MySQL commands work:
-- List all databases
SHOW DATABASES;

-- Select database
USE database_name;

-- List all tables
SHOW TABLES;

-- Describe table structure
DESCRIBE table_name;

-- Show current user
SELECT USER();

-- Show current database
SELECT DATABASE();

-- Show MariaDB version
SELECT VERSION();

-- Create database
CREATE DATABASE new_database;

-- Create user
CREATE USER 'new_user'@'%' IDENTIFIED BY 'password';

-- Grant privileges
GRANT ALL PRIVILEGES ON myapp.* TO 'myuser'@'%';
FLUSH PRIVILEGES;

MariaDB-Specific Features

MariaDB offers several improvements over MySQL:

1. Better Performance

  • Improved query optimizer
  • Faster replication
  • Better thread pool implementation

2. Additional Storage Engines

  • Aria - Crash-safe MyISAM replacement
  • ColumnStore - Columnar storage for analytics
  • Spider - Sharding and partitioning

3. Enhanced JSON Support

MariaDB 10.2+ includes JSON functions:
-- Create table with JSON column
CREATE TABLE users (
  id INT PRIMARY KEY,
  metadata JSON
);

-- Query JSON data
SELECT JSON_VALUE(metadata, '$.name') FROM users;

4. Temporal Tables

System-versioned tables for historical data:
CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  salary DECIMAL(10,2)
) WITH SYSTEM VERSIONING;

Backups

Dokploy provides automated backup functionality for MariaDB. Backups are performed using mariadb-dump (or mysqldump):
mariadb-dump -u username -p database > backup.sql
See the Backups page for detailed backup configuration.

Troubleshooting

Connection Refused

  • Verify the service is running in Dokploy UI
  • Check the service name matches your appName
  • Ensure your application is in the same Docker network

Authentication Failed

  • Verify credentials in the database settings
  • Check user has proper host permissions (% or specific IP)
  • Verify MARIADB_ environment variables are set correctly

Migration from MySQL

MariaDB is generally compatible with MySQL, but:
  1. Test thoroughly before production migration
  2. Check for MySQL-specific features not in MariaDB
  3. Review version compatibility (e.g., MariaDB 10.6 ≈ MySQL 8.0)
  4. Use mariadb-upgrade after migration

Best Practices

  1. Use Specific Versions - Pin to specific MariaDB versions (e.g., mariadb:10.11.6) instead of latest
  2. Strong Passwords - Use strong, randomly generated passwords for production
  3. Regular Backups - Configure automated backups and test restoration
  4. Monitor Resources - Watch memory and CPU usage, adjust limits as needed
  5. Security - Don’t expose MariaDB externally unless necessary
  6. Upgrade Path - Plan upgrades carefully; test in staging first
  7. Connection Pooling - Use connection pooling in your applications

Performance Tuning

Add these configuration options via environment variables or custom config:
# InnoDB buffer pool (50-70% of memory)
innodb_buffer_pool_size=1G

# Thread pool (MariaDB feature)
thread_handling=pool-of-threads
thread_pool_size=8

# Max connections
max_connections=150

# Query cache (deprecated in recent versions)
query_cache_type=0

# Aria storage engine settings
aria_pagecache_buffer_size=128M
MariaDB’s thread pool can significantly improve performance under high concurrency. Enable it with thread_handling=pool-of-threads.

MariaDB vs MySQL

FeatureMariaDBMySQL
LicenseGPLGPL (Oracle)
PerformanceGenerally fasterGood
Storage EnginesMore optionsStandard
JSON SupportYesYes (better in 8.0+)
Thread PoolYes (built-in)Enterprise only
CommunityActive communityOracle-backed
CompatibilityMySQL compatible-

Next Steps

Backups

Configure automated MariaDB backups

MySQL

Compare with MySQL documentation

Build docs developers (and LLMs) love