Vidensdatabase

Installing MySQL and MariaDB Udskriv

  • mysql, mariadb, database, sql
  • 0

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 ```

  1. Enable and start the service:

bash sudo systemctl enable --now mariadb # or mysqld for MySQL sudo systemctl status mariadb

  1. Run the security script to set a root password, remove anonymous users and disallow remote root login:

bash sudo mysql_secure_installation

  1. Log in and verify:

bash sudo mysql -u root -p SHOW DATABASES;

  1. 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;

  1. For remote access, edit bind-address in /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 use sudo mysql (unix_socket auth); reset the password with ALTER USER.
  • Problem: Service will not start. Solution: Check journalctl -u mariadb and verify the data directory ownership and free disk space.
  • Problem: Remote connection refused. Solution: Confirm bind-address is not 127.0.0.1 and the firewall allows 3306 for the specific source IP.

Related articles

  • [Managing databases from the command line]
  • [Installing phpMyAdmin]
  • [Installing PHP and common extensions]

Hjalp dette svar dig?

« Tilbage