Skip to content
Runbook

Install MariaDB on Arch

Open source SQL database, a community-developed drop-in replacement for MySQL.

Databasesqlrdbmsrelationaldatabaseacidmysql-compatible

Installation

Server (Arch repositories) · pacman
sudo pacman -S mariadb

On Arch, mariadb is the native MySQL-compatible database (no AUR needed).

Initialize the data directory · pacman
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

MANDATORY before the first start: the data directory is not created automatically.

Verify the installation

Verify
mariadb --version

Service

Start
sudo systemctl start mariadb
Stop
sudo systemctl stop mariadb
Status
sudo systemctl status mariadb
Restart
sudo systemctl restart mariadb
On boot
sudo systemctl enable mariadb

Important files

TypePathDescription
config/etc/my.cnf.dConfiguration directory (drop-in .cnf files).
data/var/lib/mysqlData directory created by mariadb-install-db.

Default ports

3306

Command-line tools

  • mariadbInteractive SQL client (mysql is kept as a symlink).
  • mariadbdThe database server daemon.
  • mariadb-adminAdministrative client.
  • mariadb-secure-installationHardening script for the installation.

Uninstall

Uninstall
sudo systemctl stop mariadb
sudo pacman -Rs mariadb

The /var/lib/mysql directory remains; delete it manually to wipe everything.

Good to know

  • Unlike Debian/Fedora, Arch does NOT initialize the data directory automatically: run mariadb-install-db before the first start.
  • On Arch, the official mysql package IS MariaDB, so this is the native route.
  • Run mariadb-secure-installation after the first start to set the root password.

Installation on Arch Linux

On Arch, the official mysql provider is MariaDB, so sudo pacman -S mariadb is the native, repository-supported route (no AUR required). This is the platform MySQL itself cannot cover natively.

Mandatory step: initialize the data directory

Unlike Debian/Ubuntu and Fedora, Arch does not create the data directory at install time. Initialize it explicitly before the first start:

sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Only then can you sudo systemctl enable --now mariadb. Forgetting this command is the most common cause of startup failure on Arch.

Securing the installation

After the first start, run sudo mariadb-secure-installation to set the root password, remove anonymous accounts, and drop the test database. The configuration lives in /etc/my.cnf.d/ as drop-in files.