MariaDB 11.4
MariaDB is an open-source relational database management system and a drop-in replacement for MySQL. It is widely used for web applications, content management systems, and general-purpose data storage.
Software included
Section titled “Software included”| Component | Version |
|---|---|
| MariaDB Server | 11.4.x (LTS) |
| Ubuntu | 24.04 LTS |
Getting started
Section titled “Getting started”1. Connect to your VM
Section titled “1. Connect to your VM”ssh ubuntu@<your-vm-ip>2. Wait for first-boot configuration
Section titled “2. Wait for first-boot configuration”On the first boot, a setup script runs automatically. It:
- Sets a random root password
- Removes anonymous users and the test database
- Creates an
appdatabase and anappuser with a random password - Writes all credentials to
/etc/mariadb/credentials.txt - Configures
/root/.my.cnfso root can connect without typing a password
This takes under 30 seconds. Track progress:
journalctl -u mariadb-first-boot.service -f3. Retrieve credentials
Section titled “3. Retrieve credentials”sudo cat /etc/mariadb/credentials.txtThis file contains the root password, application database name, application user, and application password. It is only readable by root.
4. Connect to MariaDB
Section titled “4. Connect to MariaDB”As root (no password prompt):
sudo mariadbAs the application user:
APP_PASS=$(sudo awk '/^Application password:/{print $NF}' /etc/mariadb/credentials.txt)mariadb -u app -p"$APP_PASS" appManaging MariaDB
Section titled “Managing MariaDB”# Check service statussystemctl status mariadb
# Restartsudo systemctl restart mariadb
# View logssudo journalctl -u mariadb -fConfiguration directory: /etc/mysql/mariadb.conf.d/
To allow remote connections, edit /etc/mysql/mariadb.conf.d/50-server.cnf and change
bind-address from 127.0.0.1 to 0.0.0.0, then restart MariaDB. Open the firewall for specific
IPs only (see Security).
Security
Section titled “Security”Port 3306 is not open externally by default. UFW is enabled and allows SSH (port 22) only.
To allow access from a specific IP:
sudo ufw allow from <trusted-ip> to any port 3306To connect without opening the firewall (recommended), use an SSH tunnel:
# Run this on your local machinessh -L 3306:localhost:3306 ubuntu@<your-vm-ip>
# Then connect locallymariadb -u app -p"<app-password>" app