MySQL and its fork MariaDB power a huge share of the web, from WordPress and WooCommerce to Laravel and custom applications. They are easy to install and easy to run badly. This guide focuses on what turns a default install into a production database: security, backups you can restore precisely, replication and maintenance. Tuning details are in our database tuning guide.
MySQL or MariaDB?
Both are mature and compatible for typical application SQL, but they have diverged in features, replication details and tooling. Use what your application documents and supports. MySQL 8.x LTS releases and MariaDB LTS releases both receive long-term security updates; pick an LTS release and stay on it.
Install and Secure
# MariaDB from the distribution
sudo apt install -y mariadb-server
# or MySQL from Oracle's official APT repository
sudo mysql_secure_installation
The secure installation script removes anonymous users and the test database and restricts root login. Then:
bind-address = 127.0.0.1if the application is on the same server, otherwise the private IP.- Allow port 3306 in the firewall only from application servers.
- Require TLS for remote users:
CREATE USER ... REQUIRE SSL; - Never let applications connect as root.
CREATE DATABASE shop CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'shop'@'10.0.0.11' IDENTIFIED BY 'long-random-password' REQUIRE SSL;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, DROP ON shop.* TO 'shop'@'10.0.0.11';
Core InnoDB Settings
| Setting | Starting point (dedicated 32 GB server) | Why |
|---|---|---|
innodb_buffer_pool_size | 20–22G | Keeps data and indexes in memory |
innodb_redo_log_capacity (MySQL 8.0.30+) or innodb_log_file_size | 2–4G total | Smoother write performance |
innodb_flush_log_at_trx_commit | 1 | Full durability on commit (the safe default) |
innodb_flush_method | O_DIRECT | Avoids double caching |
max_connections | 150–300 | Match app workers; avoid hundreds of idle connections |
slow_query_log | ON, long_query_time = 1 | Find slow queries |
Keep innodb_flush_log_at_trx_commit = 1 and sync_binlog = 1 for data you cannot afford to lose; relaxing them trades durability for speed.
Enable the Binary Log
[mysqld]
server_id = 1
log_bin = /var/lib/mysql/binlog
binlog_format = ROW
binlog_expire_logs_seconds = 604800 # MySQL 8; MariaDB uses expire_logs_days
sync_binlog = 1
The binary log is needed for replication and for point-in-time recovery: a backup plus the binlogs since then lets you replay changes up to just before a mistake.
Backups
| Tool | Type | Best for |
|---|---|---|
mysqldump --single-transaction | Logical, consistent for InnoDB | Databases up to tens of GB; portable |
| Percona XtraBackup (MySQL) / Mariabackup (MariaDB) | Physical, hot | Large databases; fast restore |
| Binlog archiving | Continuous change log | Point-in-time recovery between backups |
# nightly logical backup with binlog position recorded (MySQL 8.0.26+ syntax)
mysqldump --single-transaction --routines --triggers --events \
--source-data=2 --all-databases | gzip > /var/backups/mysql-$(date +%F).sql.gz
On older MySQL and on MariaDB the option is --master-data=2. Copy backups and binlogs off the server, encrypt them, and practise a full restore plus binlog replay with mysqlbinlog --stop-datetime on a test server.
Replication
A replica keeps a live copy on another server for fast failover and for offloading reads:
- Give each server a unique
server_id; enable binlogs on the source. - Create a replication user on the source with the
REPLICATION SLAVEprivilege (TLS required). - Seed the replica from a consistent backup that records the binlog position, or use GTIDs for simpler positioning.
- Point the replica at the source (
CHANGE REPLICATION SOURCE TO ...on MySQL 8.0.23+,CHANGE MASTER TO ...on MariaDB and older MySQL) and start it. - Set
read_only = ON(andsuper_read_onlyon MySQL) on the replica.
Monitor replica lag and errors, and rehearse promoting the replica. A replica is not a backup: an accidental DROP TABLE replicates in seconds.
Maintenance
- Apply minor version updates promptly after reading release notes.
- Review the slow query log weekly; add indexes or fix queries (see our tuning guide).
- Use online schema change tools (gh-ost or pt-online-schema-change) or
ALGORITHM=INPLACE/INSTANTwhere supported for large-table changes. - Purge old binlogs automatically with the expiry setting; never delete binlog files manually.
- Keep at least 20% free disk space for temporary tables, backups and growth.
Upgrades
Major upgrades (for example MySQL 8.0 to 8.4 LTS, or MariaDB 10.11 to 11.4) change defaults and remove deprecated features. Read the upgrade notes, test on a restored copy, back up, then upgrade. For minimal downtime, upgrade a replica first, then promote it.
Monitoring
Track queries per second, connections, buffer pool hit rate, slow queries, replication lag and errors, InnoDB row lock waits and disk space. The Prometheus MySQL exporter covers these; alert on replication stopping and on backups failing (see our monitoring guide).
Sizing
| Database | EPYC plan |
|---|---|
| WordPress or small app sharing the server | 2 vCores / 8 GB |
| WooCommerce or business app, database on the same server | 4 vCores / 16 GB |
| Dedicated database for a busy application | 8 vCores / 32 GB |
| Large datasets and heavy concurrency | 16 vCores / 64 GB |
Notes for WordPress and WooCommerce
Most WordPress tables use InnoDB today; convert any remaining MyISAM tables so backups are consistent and crash recovery works. WooCommerce stores many order details in post meta or in its newer order tables; large shops benefit from high-performance order storage, sensible indexes and regular cleanup of expired sessions and transients. An object cache such as Redis removes many repeated queries (see our Redis guide).
Character Set and Collation
Use utf8mb4 everywhere, so emoji and all scripts are stored correctly. Mixing character sets between the server, databases, tables and connections causes subtle bugs and slow joins. Set the defaults in the server configuration and specify them explicitly when creating databases.
Time Zones
Store timestamps in UTC and convert in the application. Load the time zone tables (mysql_tzinfo_to_sql) if you use named time zones in SQL.
Production Checklist
- Bound to localhost or a private IP; port allowed only from app servers.
- Per-application users with least privilege and TLS for remote access.
- Binary log enabled; nightly consistent backups copied off-site.
- A restore plus binlog replay rehearsed on a test server.
- Slow query log reviewed weekly.
SkyRainCloud Plans for This Workload
MySQL performance depends on the InnoDB buffer pool fitting your hot data: a dedicated database on 8 vCores / 32 GB or 16 vCores / 64 GB holds large working sets in memory. Smaller sites share a 2–4 vCore server with their application.
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.