🐬 Setup MariaDB — MySQL-Compatible Database
Deploy MariaDB MySQL-compatible database on Ubuntu using Docker — open-source, fast, and used by WordPress, ERPNext, and Dolibarr.
📦 Resources & Setup Scripts
Grab the automated bash script from GitHub to follow along with the video.
Quick Install:
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/mariadb/mariadb-ubuntu.sh
chmod +x mariadb-ubuntu.sh
sudo bash mariadb-ubuntu.sh
Tutorial Steps
1 Download the Script
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/mariadb/mariadb-ubuntu.sh
2 Make it Executable
chmod +x mariadb-ubuntu.sh
3 Run the Installer
The script installs Docker if needed, then deploys MariaDB with secure defaults.
sudo bash mariadb-ubuntu.sh
4 Connect to MariaDB
Connect via CLI or any MySQL-compatible client:
docker exec -it mariadb mariadb -u root -p
5 Create Database and User
Create your first database and a dedicated user with limited privileges — never use root for applications.
CREATE DATABASE myapp;
CREATE USER 'appuser'@'%' IDENTIFIED BY 'StrongPassword!';
GRANT ALL PRIVILEGES ON myapp.* TO 'appuser'@'%';
FLUSH PRIVILEGES;
Ports Used
| Port | Purpose |
|---|---|
| 3306 | MariaDB — internal, expose only if needed |
Overview
MariaDB is a community-developed, open-source relational database that is fully compatible with MySQL. It powers millions of production applications worldwide and is the drop-in replacement of choice for teams who want an actively maintained, performance-focused alternative to MySQL.
Why Use It
MariaDB is the community-driven MySQL fork that most Linux distributions now ship by default. It's 100% MySQL-compatible (same client, same SQL, same connection strings) but faster on read-heavy workloads, adds features MySQL Enterprise charges for (like Galera Cluster for active-active replication), and is free forever. If your app says 'requires MySQL', MariaDB works without changes.
When You Need It
Who Should Use It
Real Use Cases
Main Features
How to Use After Installation
Security Best Practices
Ports and Firewall Notes
Port 3306 for MariaDB. Keep it strictly internal — applications connect via Docker's internal network. Never expose 3306 to the internet. Use an SSH tunnel or a management UI like Adminer behind a reverse proxy for remote access.
Backup and Maintenance
Common Mistakes
Troubleshooting
Alternatives
Direct alternatives: MySQL (Oracle-owned, same SQL), PostgreSQL (more advanced features, better for complex queries and JSON), SQLite (no server, file-based, for single-app use). MariaDB wins for MySQL-compatible apps where you want community ownership and Galera clustering free.
When Not to Use It
Don't use MariaDB if you need advanced PostgreSQL features (JSON, full-text search, window functions, PostGIS). And for very simple single-app deployments where a full RDBMS is overkill, SQLite is simpler. MariaDB shines for MySQL-compatible apps and multi-application shared database servers.
PrismaTechWork Professional Help
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
Frequently Asked Questions
Is MariaDB 100% compatible with MySQL?
For the vast majority of use cases, yes — same SQL syntax, same protocol, same client libraries. Some MySQL 8.0 features (caching_sha2_password by default, specific JSON functions) may differ slightly. WordPress, Dolibarr, ERPNext, and most MySQL apps work without changes.
What is the default root password after installation?
The root password is set via the `MARIADB_ROOT_PASSWORD` environment variable in your docker-compose file. Change it from the default before going to production and never use root in application connection strings.
How do I create a new database and user for an application?
Connect as root then run: `CREATE DATABASE myapp; CREATE USER 'myapp'@'%' IDENTIFIED BY 'strongpassword'; GRANT ALL PRIVILEGES ON myapp.* TO 'myapp'@'%'; FLUSH PRIVILEGES;` — replace `%` with a specific IP for tighter security.
What is Galera Cluster?
Galera is a synchronous multi-master replication plugin — all nodes accept writes and data is consistent across all nodes. Unlike MySQL's primary-replica setup, any Galera node can be the write node. It requires at least 3 nodes for quorum.
How do I tune MariaDB for better performance?
Key tuning parameters: `innodb_buffer_pool_size` = 70-80% of RAM, `innodb_log_file_size` = 256M, `max_connections` = based on your concurrent connection count, `query_cache_size = 0` (disable — query cache is deprecated and harmful under load). Use MySQLTuner script for recommendations.
Is there a web-based GUI for MariaDB?
Yes — Adminer (lightweight, single PHP file) and phpMyAdmin (full-featured) both work with MariaDB. For production, run Adminer or phpMyAdmin behind Nginx Proxy Manager with auth enabled — never expose them publicly.
Can MariaDB replace MySQL in existing applications?
For most applications, yes — just change the connection host. Test thoroughly, especially if using MySQL 8.0-specific features like `caching_sha2_password` (use `mysql_native_password` plugin in MariaDB for compatibility). WordPress, Joomla, Drupal, and most PHP apps work without changes.
How do I upgrade MariaDB?
Minor versions (10.11.x → 10.11.y): `docker compose pull && docker compose up -d`. Major versions (10.11 → 11.x): dump all databases first (`mysqldump --all-databases`), upgrade the container, then run `mariadb-upgrade`. Always back up before major upgrades.