Best VPS for MySQL 2026: Self-Host Your Database
Find the best VPS for hosting MySQL. Compare specs, optimize performance, and run your own database server for a fraction of managed database costs.
Best VPS for MySQL in 2026
MySQL powers over 40% of all databases on the internet — from WordPress to enterprise apps. Self-host it on a VPS and skip the $50-300/month managed database fees.
Why Self-Host MySQL?
| Factor | Managed (AWS RDS) | Self-Hosted VPS |
|---|---|---|
| 2 vCPU, 4GB RAM | $100+/mo | ~$7/mo |
| 4 vCPU, 8GB RAM | $200+/mo | ~$15/mo |
| Control | Limited | Full |
| Tuning | Restricted | Full my.cnf access |
| Backups | Extra cost | Free (you manage) |
Self-hosting costs 90% less for equivalent specs.
VPS Requirements
MySQL is RAM and I/O hungry. Here's what matters:
RAM (Critical)
- InnoDB buffer pool should hold your working dataset
- Rule of thumb: buffer pool = 70-80% of total RAM
- 4GB handles most small-to-medium apps
- 8GB+ for databases over 10GB
Storage (Critical)
- NVMe SSD is non-negotiable — random I/O performance defines MySQL speed
- Size: 2-3x your database size (for logs, temp tables, backups)
- IOPS matters more than throughput for transactional workloads
CPU
- MySQL 8 uses parallel query execution
- More cores = better for concurrent connections
- 2 vCPU for small apps, 4+ for production
Network
- Low latency to your application servers
- Same datacenter whenever possible
- 1Gbps for replication setups
Best VPS for MySQL
1. Hostinger KVM2 (Best Overall) ⭐
$5.99/mo | 2 vCPU, 8GB RAM, 100GB NVMe
8GB RAM means a 5-6GB InnoDB buffer pool — enough to keep most databases entirely in memory. 100GB NVMe gives room for data growth and backups.
Best for: Most MySQL workloads — web apps, CMS, SaaS backends
2. Hetzner CX22 (Best Budget)
€5.39/mo | 2 vCPU, 4GB RAM, 40GB NVMe
Solid AMD EPYC performance with enough RAM for a 3GB buffer pool. Great for development and small production databases.
Best for: Small apps, WordPress, development
3. Hetzner CX32 (Best for Growth)
€10.49/mo | 4 vCPU, 8GB RAM, 80GB NVMe
4 cores handle concurrent queries well, and 8GB keeps your dataset cached. Excellent price-to-performance for growing apps.
Best for: Growing SaaS apps, e-commerce databases
4. Vultr High Frequency (Best Performance)
$48/mo | 4 vCPU (3GHz+), 16GB RAM, 256GB NVMe
Highest single-core performance available. 16GB RAM for a massive buffer pool. When your database is your bottleneck.
Best for: High-traffic production, complex queries, analytics
5. Contabo VPS M (Best Value)
€10.49/mo | 6 vCPU, 16GB RAM, 200GB NVMe
Maximum RAM and storage per dollar. Perfect for large databases that need to stay in memory.
Best for: Large datasets, data warehousing, reporting databases
Quick Comparison
| VPS | RAM | vCPU | Storage | Price | Best For |
|---|---|---|---|---|---|
| Hostinger KVM2 | 8GB | 2 | 100GB NVMe | $5.99/mo | Overall best |
| Hetzner CX22 | 4GB | 2 | 40GB NVMe | €5.39/mo | Budget |
| Hetzner CX32 | 8GB | 4 | 80GB NVMe | €10.49/mo | Growth |
| Vultr HF | 16GB | 4 | 256GB NVMe | $48/mo | Performance |
| Contabo M | 16GB | 6 | 200GB NVMe | €10.49/mo | Best value |
How to Install MySQL
Ubuntu/Debian
# Install MySQL 8
sudo apt update && sudo apt install -y mysql-server
# Secure installation
sudo mysql_secure_installation
Key configuration in /etc/mysql/mysql.conf.d/mysqld.cnf:
[mysqld]
# InnoDB Buffer Pool (70-80% of RAM)
innodb_buffer_pool_size = 6G
# Log file size (25% of buffer pool)
innodb_log_file_size = 1G
# Flush method for best SSD performance
innodb_flush_method = O_DIRECT
# Connection limits
max_connections = 200
# Temp table size
tmp_table_size = 64M
max_heap_table_size = 64M
# Query cache (disabled in MySQL 8 — use ProxySQL if needed)
# Slow query log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
# Binary logging for replication/PITR
log_bin = mysql-bin
binlog_expire_logs_seconds = 604800
sudo systemctl restart mysql
sudo systemctl enable mysql
Docker (Recommended)
# docker-compose.yml
version: "3.8"
services:
mysql:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: your-strong-password
MYSQL_DATABASE: myapp
MYSQL_USER: appuser
MYSQL_PASSWORD: app-password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./my-custom.cnf:/etc/mysql/conf.d/custom.cnf
command: >
--innodb-buffer-pool-size=6G
--innodb-log-file-size=1G
--innodb-flush-method=O_DIRECT
--max-connections=200
volumes:
mysql_data:
docker compose up -d
Performance Tuning
InnoDB Optimization
# Buffer pool instances (1 per GB)
innodb_buffer_pool_instances = 6
# Read/write I/O threads
innodb_read_io_threads = 4
innodb_write_io_threads = 4
# Adaptive flushing for SSDs
innodb_adaptive_flushing = ON
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
# Redo log optimization
innodb_flush_log_at_trx_commit = 1
innodb_flush_neighbors = 0
Query Performance
# Find slow queries
mysqldumpslow -s t /var/log/mysql/slow.log
# Check buffer pool hit ratio
mysql -e "SHOW STATUS LIKE 'Innodb_buffer_pool_read%';"
# Monitor connections
mysql -e "SHOW STATUS LIKE 'Threads_%';"
System Tuning
# Increase open file limits
echo "mysql soft nofile 65535" >> /etc/security/limits.conf
echo "mysql hard nofile 65535" >> /etc/security/limits.conf
# I/O scheduler for SSDs
echo "none" > /sys/block/sda/queue/scheduler
# Swappiness (keep data in RAM)
echo "vm.swappiness = 10" >> /etc/sysctl.conf
sysctl -p
Backup Strategy
Automated Backups with mysqldump
#!/bin/bash
# /usr/local/bin/mysql-backup.sh
DATE=$(date +%Y%m%d_%H%M)
BACKUP_DIR="/backups/mysql"
mkdir -p $BACKUP_DIR
mysqldump --all-databases --single-transaction \
--routines --triggers --events \
-u root -p"$MYSQL_ROOT_PASSWORD" \
| gzip > "$BACKUP_DIR/all-databases-$DATE.sql.gz"
# Keep last 7 days
find $BACKUP_DIR -name "*.sql.gz" -mtime +7 -delete
# Run daily at 3 AM
echo "0 3 * * * /usr/local/bin/mysql-backup.sh" | crontab -
Point-in-Time Recovery
Enable binary logging (shown above) for PITR capability. Combined with daily full backups, you can recover to any point in time.
Security Checklist
- Run
mysql_secure_installation - Never expose port 3306 to the internet
- Use firewall rules (ufw/iptables)
- Create app-specific users with minimal privileges
- Enable SSL/TLS for remote connections
- Set up automated backups
- Monitor slow query log
- Keep MySQL updated
# Firewall: only allow your app server
sudo ufw allow from YOUR_APP_IP to any port 3306
sudo ufw deny 3306
# Create limited user
mysql -e "CREATE USER 'appuser'@'%' IDENTIFIED BY 'strong-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON myapp.* TO 'appuser'@'%';
FLUSH PRIVILEGES;"
MySQL vs Managed Alternatives
| Service | 4GB RAM | Control | Latency |
|---|---|---|---|
| AWS RDS | $100+/mo | Low | ~1ms |
| PlanetScale | $39+/mo | Medium | ~5ms |
| DigitalOcean Managed | $60+/mo | Medium | ~2ms |
| Self-Hosted VPS | $6-15/mo | Full | <1ms |
Self-hosted MySQL on a VPS in the same datacenter gives you lowest latency, full control, and massive cost savings.
FAQ
How much RAM do I need for MySQL?
Your InnoDB buffer pool should fit your working dataset. Start with 4GB total (3GB buffer pool) and upgrade when buffer pool hit ratio drops below 99%.
Is MySQL safe to run on a VPS?
Yes. Use strong passwords, firewall rules, and never expose port 3306 publicly. Automated backups give you peace of mind.
MySQL or PostgreSQL?
Both are excellent. MySQL is simpler to set up and has more hosting ecosystem support (WordPress, most PHP apps). PostgreSQL wins for complex queries and advanced data types. Check our PostgreSQL VPS guide too.
Can a $6/month VPS handle production MySQL?
Yes. For small-to-medium apps (under 10GB database, under 100 concurrent connections), a 2 vCPU / 8GB RAM VPS handles it easily. MySQL is well-optimized and runs great on modest hardware.
Our Pick
Hostinger KVM2 at $5.99/month gives you 8GB RAM and 100GB NVMe — enough for a well-tuned MySQL server handling real production traffic. That's less than a single month of any managed database service.
Ready to get started?
Get the best VPS hosting deal today. Hostinger offers 4GB RAM VPS starting at just $4.99/mo.
Get Hostinger VPS — $4.99/mo// up to 75% off + free domain included
// related topics
fordnox
Expert VPS reviews and hosting guides. We test every provider we recommend.
// last updated: February 14, 2026. Disclosure: This article may contain affiliate links.