Summary: Ubuntu 24.04’s repo installs MariaDB 10.11.x. This guide adds MariaDB’s official APT repo to install MariaDB 11.4, secures the server, creates a database/user, and verifies remote access.
MariaDB vs MySQL
- Origin: MariaDB is a community fork of MySQL (by the original MySQL creators).
- Compatibility: Basic SQL is similar, but they’ve diverged—don’t assume drop-in compatibility for advanced features.
- JSON: MySQL has a native JSON type; MariaDB’s
JSON
is aLONGTEXT
alias with JSON functions (semantics/indexing differ). - Clustering: MariaDB integrates Galera (multi-primary); MySQL offers Group Replication / InnoDB Cluster.
Prerequisites
- Ubuntu 24.04 server with sudo
- (Optional) UFW for firewall rules
- Add MariaDB’s repo (11.4) with keyring +
.sources
sudo apt-get update
sudo apt-get install -y apt-transport-https curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
Create /etc/apt/sources.list.d/mariadb.sources
with this content:
X-Repolib-Name: MariaDB
Types: deb
URIs: https://deb.mariadb.org/11.4/ubuntu
Suites: noble
Components: main main/debug
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
Update APT:
sudo apt-get update
- Install MariaDB 11.4
sudo apt-get install -y mariadb-server
sudo systemctl enable --now mariadb
mariadb --version
- Secure the server
sudo mysql_secure_installation
Tip: On Ubuntu/Debian, root@localhost
usually authenticates via unix_socket. Use sudo mariadb
to log in as root; create separate admin/app users for password logins.
- Create a database and local app user
# Login as root via socket
sudo mariadb
CREATE DATABASE appdb
DEFAULT CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'CHANGE_ME';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Local test:
mariadb -u appuser -p -e "SHOW DATABASES LIKE 'appdb';"
- Enable and test remote access (safe pattern)
- Configure MariaDB to listen on the network & use IP-based grants
Edit /etc/mysql/mariadb.conf.d/50-server.cnf
:
[mysqld]
bind-address = 0.0.0.0
skip_name_resolve = ON
Apply:
sudo systemctl restart mariadb
Why skip_name_resolve=ON
?
It disables reverse DNS so host matching uses the client IP, making patterns like '192.168.0.%'
work reliably.
- Create a network-scoped user (least privilege)
sudo mariadb
CREATE USER 'appuser'@'192.168.0.%' IDENTIFIED BY 'CHANGE_ME';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'192.168.0.%';
FLUSH PRIVILEGES;
FLUSH HOSTS;
EXIT;
- Open the firewall (server)
# Replace with your trusted CIDR or a single IP
sudo ufw allow from 192.168.0.0/24 to any port 3306 proto tcp
- Remote access test (from another machine)
Install a client if needed:
sudo apt-get install -y mariadb-client
Run the test:
mariadb --protocol=TCP -h <SERVER_IP> -u appuser -p \
-e "SELECT VERSION() AS version, @@hostname AS server, CURRENT_USER() AS you;"
Sample output (working):
+------------------------+--------+----------------------+
| version | server | you |
+------------------------+--------+----------------------+
| 11.4.8-MariaDB-ubu2404 | test | appuser@192.168.0.90 |
+------------------------+--------+----------------------+