Deploy MariaDB
Fast, reliable MySQL-compatible relational database.
mariadb
Just deployed
/var/lib/mysql
Deploy and Host MariaDB on Railway
MariaDB is an open-source relational database designed as a MySQL-compatible database server for web applications, APIs, CMS platforms, analytics workloads, and general-purpose transactional systems. It provides SQL, transactions, indexing, replication capabilities, and broad compatibility with tools and applications built for the MySQL ecosystem.
About Hosting MariaDB
Hosting MariaDB on Railway gives you a persistent relational database without manually managing a virtual machine, operating system, database package installation, or server lifecycle.
This template runs the official MariaDB Docker image and stores database files in a persistent Railway volume. Applications inside the same Railway project can connect through Railway private networking on port 3306, while external database clients can connect through Railway TCP Proxy.
The deployment creates a root administrator account, a default application database, and a dedicated application user so applications do not need to connect using the root account.
Common Use Cases
- Backend databases for web applications and APIs
- WordPress and other MySQL-compatible CMS platforms
- Transactional application data
- Internal business applications
- E-commerce and SaaS backends
- Development and testing environments
- Applications migrating from or compatible with MySQL
Dependencies for MariaDB Hosting
- Official
mariadb:ltsDocker image - Persistent Railway volume mounted at
/var/lib/mysql
Implementation Details
MariaDB stores its persistent database files at:
/var/lib/mysql
A Railway volume is mounted at this location so databases, tables, indexes, users, and other database state remain available across container restarts and redeployments.
The database server communicates using the MySQL/MariaDB wire protocol on:
TCP 3306
MariaDB is not an HTTP service, so external access should use Railway TCP Proxy rather than a standard HTTP public domain.
Database Users
This template initializes two credential levels:
- Root user — intended for database administration
- Application user — intended for normal application connections
Applications should normally use the dedicated application user rather than connecting as root.
This helps keep administrative privileges separate from day-to-day application access.
Database Connection
Applications Inside Railway
Services running inside the same Railway project should use Railway private networking.
The private connection uses:
:3306
A private connection URL can be referenced directly from the MariaDB service variables.
Using private networking keeps database traffic inside the Railway project and avoids exposing the database unnecessarily to the public internet.
External Database Clients
For tools running outside Railway, such as:
- DBeaver
- HeidiSQL
- MySQL Workbench
- TablePlus
- command-line MySQL/MariaDB clients
use the Railway TCP Proxy hostname and port shown in the MariaDB service settings.
The TCP Proxy provides an externally reachable hostname and dynamically assigned port that forwards connections to MariaDB port 3306.
Connecting with a MariaDB Client
A typical connection uses:
Host:
Port:
Database: app
Username: mariadb
Password:
You can also use the generated connection URL exposed by the Railway service.
Example connection URI structure:
mysql://mariadb:PASSWORD@HOST:PORT/app
Test the Database
After connecting, verify the MariaDB server version:
SELECT VERSION();
Check the active database:
SELECT DATABASE();
Create a simple table:
CREATE TABLE users (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Insert a record:
INSERT INTO users (name, email)
VALUES ('Example User', 'user@example.com');
Query the table:
SELECT *
FROM users;
MariaDB vs Similar Relational Databases
| Feature | MariaDB | MySQL | PostgreSQL | SQLite |
|---|---|---|---|---|
| Open source | ✅ | ✅ | ✅ | ✅ |
| MySQL protocol compatibility | ✅ | ✅ | ❌ | ❌ |
| SQL relational database | ✅ | ✅ | ✅ | ✅ |
| Multi-user server | ✅ | ✅ | ✅ | ❌ |
| Persistent network database | ✅ | ✅ | ✅ | ❌ |
| Transactions | ✅ | ✅ | ✅ | ✅ |
| Replication support | ✅ | ✅ | ✅ | ❌ |
| Suitable for CMS platforms | ✅ | ✅ | ✅ | ❌ |
| Single-file embedded database | ❌ | ❌ | ❌ | ✅ |
MariaDB is particularly useful when you need a familiar MySQL-compatible relational database while preferring an open-source database server with broad ecosystem compatibility.
Applications already designed for MySQL can often connect to MariaDB with little or no modification, although compatibility should still be verified for features that depend on a specific database version or MySQL-specific behavior.
Getting Started After Deployment
- Deploy the MariaDB template.
- Wait for the database service to become available.
- Retrieve the application username, password, and database name from the service variables.
- For applications inside Railway, use the private database connection URL.
- For applications outside Railway, enable or use the Railway TCP Proxy.
- Connect using DBeaver, HeidiSQL, MySQL Workbench, a MariaDB client, or your application.
- Run:
SELECT VERSION();
- Create your application tables and begin using the database.
Why Deploy MariaDB on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying MariaDB on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
mariadb
mariadb:lts