MySQL is one of the world’s most popular open-source relational database management systems, trusted for web applications and data-driven solutions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/dokploy/dokploy/llms.txt
Use this file to discover all available pages before exploring further.
Creating a MySQL Database
Navigate to Databases
In your Dokploy dashboard, select your environment and click Add Database > MySQL.
Configure Basic Settings
Fill in the required information:
- Name: Display name for the database
- App Name: Internal DNS name (e.g.,
mysql-app) - Description: Optional notes
- Docker Image: MySQL version (default:
mysql:8)
Set Database Credentials
MySQL requires both root and application credentials:
The root password is used for administrative tasks. The database user is for application connections.
Connection Information
- Internal Connection
- External Connection
- Root Access
Applications in the same environment use internal DNS:Connection String Example:
Configuration
Environment Variables
Customize MySQL behavior with environment variables:Resource Allocation
| Workload Type | Memory Reservation | Memory Limit | CPU Reservation | CPU Limit |
|---|---|---|---|---|
| Development | 128MB | 256MB | 0.1 | 0.25 |
| Small Production | 256MB | 512MB | 0.25 | 0.5 |
| Medium Production | 512MB | 1GB | 0.5 | 1.0 |
| Large Production | 1GB | 4GB | 1.0 | 2.0 |
Docker Image Versions
MySQL offers several version options:Database Operations
Lifecycle Management
Manage your MySQL database through the UI:- Start/Stop
- Reload
- Rebuild
Start: Brings database online (status: Stop: Gracefully shuts down (status:
done)idle)Move Between Environments
Transfer databases between environments (dev, staging, production):- Navigate to database settings
- Select Move to Environment
- Choose target environment
- Confirm the move
Moving updates the environment reference but doesn’t migrate data. Use backups to transfer data.
Volume Management
MySQL data persists in a Docker volume:- Database files (
.ibd,.frm) - InnoDB tablespace
- Binary logs
- MySQL configuration
Volume Backup
See Database Backups for automated backup configuration.Advanced Configuration
Custom Startup Options
Override MySQL server startup configuration: Command:Health Check Configuration
Ensure MySQL is monitored and auto-recovers:Restart Policy
Automatic restart on failure:Common Use Cases
- Web Application
- High Performance
- Development
Standard MySQL setup for web apps:
Monitoring and Logs
View MySQL logs in real-time:- Navigate to your MySQL service
- Click Logs tab
- Monitor database activity
Troubleshooting
Database initialization failed
Database initialization failed
Check container logs for initialization errors:Common causes:
- Invalid root or database password format
- Insufficient disk space for data directory
- Corrupted volume from previous deployment
- Verify password format (no special characters)
- Check disk space availability
- If needed, delete and recreate the database
Connection refused
Connection refused
Verify connection details:
- Host: Use app name for internal, server address for external
- Port: 3306 internal, configured external port
- Status: Ensure database status is
done - Firewall: Check that port is accessible
Out of memory errors
Out of memory errors
MySQL exceeding allocated memory:
- Increase Memory Limit in settings
- Reduce InnoDB buffer pool:
- Limit connections:
- Redeploy the database
Slow performance
Slow performance
Optimize MySQL configuration:
- Increase memory allocation
- Tune InnoDB settings:
- Enable and check slow query log
- Consider upgrading to SSD storage
Character encoding issues
Character encoding issues
Set proper character encoding:Redeploy and verify:
Migration from Other Databases
From PostgreSQL
Key differences to consider:- Auto-increment: Use
AUTO_INCREMENTinstead ofSERIAL - Boolean: Use
TINYINT(1)instead ofBOOLEAN - Schemas: MySQL uses databases instead of schemas
- Case sensitivity: Table names are case-insensitive by default
From MySQL 5.7 to 8.0
Major changes:- Authentication: MySQL 8 uses
caching_sha2_passwordby default - Reserved words: New reserved keywords in 8.0
- Performance: Improved query optimizer and indexing
- JSON: Enhanced JSON support and functions
Next Steps
Setup Backups
Configure automated MySQL backups
MariaDB
Learn about MariaDB as MySQL alternative