Overview
MySQL and MariaDB are the two most common relational databases on Linux. MariaDB is a
drop-in, community-developed fork of MySQL, and most distributions ship MariaDB as the
default mysql package. This article shows how to install either one on an ALYPOD CPU
Pod and run the initial security hardening.
Before you begin
- A CPU Pod with root/sudo access (Debian/Ubuntu or RHEL family).
- At least 1 GB RAM for small workloads; more for production.
- Port 3306 open only if remote database access is required.
Steps
Install MariaDB
```bash
Debian / Ubuntu
sudo apt update && sudo apt install -y mariadb-server
RHEL / AlmaLinux / Rocky
sudo dnf install -y mariadb-server ```
Install MySQL (Oracle Community Server)
```bash
RHEL family — add the official repo
sudo dnf install -y https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm sudo dnf install -y mysql-community-server ```
- Enable and start the service:
bash
sudo systemctl enable --now mariadb # or mysqld for MySQL
sudo systemctl status mariadb
- Run the security script to set a root password, remove anonymous users and disallow remote root login:
bash
sudo mysql_secure_installation
- Log in and verify:
bash
sudo mysql -u root -p
SHOW DATABASES;
- Create an application database and user (avoid using root for apps):
sql
CREATE DATABASE appdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
- For remote access, edit
bind-addressin/etc/mysql/mariadb.conf.d/50-server.cnf(or/etc/my.cnf) and allow port 3306 in the ALYPOD firewall. Prefer SSH tunnels over exposing the database directly.
Troubleshooting
- Problem:
Access denied for user 'root'. Solution: On MariaDB usesudo mysql(unix_socket auth); reset the password withALTER USER. - Problem: Service will not start. Solution: Check
journalctl -u mariadband verify the data directory ownership and free disk space. - Problem: Remote connection refused. Solution: Confirm
bind-addressis not127.0.0.1and the firewall allows 3306 for the specific source IP.
Related articles
- [Managing databases from the command line]
- [Installing phpMyAdmin]
- [Installing PHP and common extensions]
