Deploy MariaDB MySQL-compatible database on Ubuntu using Docker — open-source, fast, and used by WordPress, ERPNext, and Dolibarr.
Grab the automated bash script from GitHub to follow along with the video.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/mariadb/mariadb-ubuntu.sh
chmod +x mariadb-ubuntu.sh
sudo bash mariadb-ubuntu.sh
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/databases/mariadb/mariadb-ubuntu.sh
chmod +x mariadb-ubuntu.sh
The script installs Docker if needed, then deploys MariaDB with secure defaults.
sudo bash mariadb-ubuntu.sh
Connect via CLI or any MySQL-compatible client:
docker exec -it mariadb mariadb -u root -p
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;
| Port | Purpose |
|---|---|
| 3306 | MariaDB — internal, expose only if needed |
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
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.
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.
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.
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.