Railway

Deploy MySQL 8 or Any Version

Choose tag MySQL version and deploy - default 8.0.35

Deploy MySQL 8 or Any Version

/var/lib/mysql

Deploy and Host

Deploy this repository as a new service on Railway. The service runs MySQL in a container and persists data to a volume. Configure MYSQL_ROOT_PASSWORD (required) and optionally MYSQL_VERSION, MYSQL_DATABASE, and MYSQL_CONFIG in the service variables.

About Hosting

This template is hosted as a Docker-based service on Railway. MySQL runs from the official Docker image; the version is chosen via the MYSQL_VERSION build variable. Data is stored in a volume mounted at /var/lib/mysql. Use Railway's TCP Proxy if you need to connect from outside Railway.

Why Deploy

  • Choose your MySQL version – Set MYSQL_VERSION (e.g. 8.0.35, 8.0.40, 5.7) instead of being locked to a single version.
  • Memory presets – Use MYSQL_CONFIG to choose between low, normal, or high memory profiles, or define custom settings.
  • Simple setup – Set MYSQL_ROOT_PASSWORD and optionally the database name; no extra config required.
  • Persistent data – Attach a volume at /var/lib/mysql so data survives redeploys.
  • General-purpose config – utf8mb4 and a strict sql_mode suitable for most applications.

Memory Presets

Control MySQL memory usage via the MYSQL_CONFIG variable:

PresetRAM (idle)Use case
low~100-200MBDevelopment, low-traffic apps, cost savings
normal~300-400MBStandard production workloads
high~500-700MBHigh-traffic, performance-critical apps

If MYSQL_CONFIG is not set, MySQL uses its built-in defaults.

Shortname Reference

ShortnameMySQL OptionDescription
ibpsinnodb_buffer_pool_sizeInnoDB buffer pool (main memory consumer)
kbskey_buffer_sizeMyISAM index cache
toctable_open_cacheNumber of open tables cache
tcsthread_cache_sizeCached threads for reuse
ttstmp_table_sizeMax size of internal in-memory temp tables
mhtsmax_heap_table_sizeMax size of MEMORY tables
ilbsinnodb_log_buffer_sizeInnoDB log buffer
mcmax_connectionsMaximum simultaneous connections
qcsquery_cache_sizeQuery cache size (MySQL 5.7 only)
qctquery_cache_typeQuery cache type (MySQL 5.7 only)
ifcinnodb_flush_log_at_trx_commitFlush behavior (1=safe, 2=fast)
ilfsinnodb_log_file_sizeInnoDB log file size
sbssort_buffer_sizeSort buffer per connection
rbsread_buffer_sizeRead buffer per connection
rrbsread_rnd_buffer_sizeRandom read buffer
jbsjoin_buffer_sizeJoin buffer per connection

You can also pass custom settings: MYSQL_CONFIG=ibps=64M,mc=75,tcs=6 or use full MySQL option names: MYSQL_CONFIG=innodb_buffer_pool_size=64M,max_connections=50

Common Use Cases

  • Backend database for web apps (Node, PHP, Python, etc.)
  • Development or staging MySQL when you need a specific version (e.g. 8.0 for Magento 2.4)
  • Low-memory MySQL for hobby projects or cost-sensitive deployments
  • Any project that needs MySQL with a configurable version on Railway

Dependencies for

This template provides a MySQL server. Your application (or other services) depend on it for database storage.

Deployment Dependencies

  • MYSQL_ROOT_PASSWORD (required) – Root password for MySQL. Set this in the service variables before or at deploy; the container will not start without it.
  • Volume – Add a volume mounted at /var/lib/mysql for persistent data. Without it, data is lost on redeploy.
  • MYSQL_VERSION (optional) – Docker image tag (e.g. 8.0.35, 5.7). Default: 8.0.35.
  • MYSQL_DATABASE (optional) – Database name created on first run. Default: railway.
  • MYSQL_CONFIG (optional) – Memory preset (low, normal, high) or custom config. If not set, MySQL uses its defaults.

Template Content

More templates in this category

View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Aman
View Template
ReadySet
A lightweight caching engine for Postgres

Milo
View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.

Joey Chilson