Tutorials  /  Databases

Install and Secure MariaDB on FreeBSD 14.0 – Step-by-Step Guide

Ccentron Redaktion · November 2025 ·5 min read ·Databases, Tutorial

MariaDB is an open-source relational database management system (RDBMS) that serves as a drop-in replacement for MySQL, offering improved performance and extended support for multiple storage engines. It uses SQL (Structured Query Language) to perform database operations and integrates easily with existing server applications, such as web server stacks, through modular extensions.

This guide explains how to install MariaDB on FreeBSD 14.0, secure the database server, and allow users to create and manage SQL records efficiently.

Prerequisites

  • Deploy a FreeBSD 14.0 server instance via our custom images feature during the server deployment in the ccloud³.
  • Access the server via SSH.
  • Create a non-root user with sudo privileges and switch to that user.
DB

Matching infrastructure at centron

Databases need care in production: centron can take over updates, backups and monitoring – from a single instance to a full cluster. Explore managed clusters →

Install MariaDB

MariaDB is included in the default FreeBSD 14.0 package repositories. Follow the steps below to install MariaDB using the pkg package manager and configure it to start automatically at boot.

Update the pkg catalog:

Console
$ sudo pkg update

Search for available MariaDB packages:

Console
$ sudo pkg search mariadb

Install the latest stable version, for example MariaDB 10.6:

Console
$ sudo pkg install -y mariadb106-server

Check the installed MariaDB version:

Console
$ mariadb --version

Temporarily start the MariaDB service to verify access:

Console
$ sudo service mysql-server onestart

Log in to the MariaDB console:

Console
$ sudo mariadb

If you see an error like:

Code
ERROR 2002 (HY000): Can't connect to local server through socket '/var/run/mysql/mysql.sock' (2)

Downgrade to a previous stable version (for example, 10.5):

Console
$ sudo pkg remove -y mariadb106-server && sudo pkg install -y mariadb105-server

Manage the MariaDB Service

MariaDB uses the mysql-server service to control the database process. The steps below show how to manage it and enable autostart at boot.

Enable MariaDB autostart:

Console
$ sudo sysrc mysql_enable="YES"

Start the MariaDB service:

Console
$ sudo service mysql-server start

Check the MariaDB service status:

Console
$ sudo service mysql-server status

Secure MariaDB

By default, MariaDB allows root login without a password. Secure your installation using the included setup script:

Run the security script:

Console
$ sudo mysql_secure_installation

Follow the prompts to:

  • Set a strong root password.
  • Disable anonymous users.
  • Prevent remote root access.
  • Remove the test database.
  • Reload privileges to apply changes.

Access the MariaDB Console

MariaDB can be accessed using the mysql or mariadb client tools. The following steps show how to log in and test basic operations.

Log in as root:

Console
$ sudo mariadb -u root -p

Create a new sample database:

Code
CREATE DATABASE demodb;

List all databases to verify creation:

Code
SHOW DATABASES;

Switch to the new database:

Code
USE demodb;

Create a new user and grant privileges:

Code
CREATE USER 'db_admin'@'localhost' IDENTIFIED BY 'strong-password';
GRANT ALL PRIVILEGES ON demodb.* TO 'db_admin'@'localhost';
FLUSH PRIVILEGES;

Exit the console:

Code
EXIT;

Test the new user login:

Console
$ sudo mysql -u db_admin -p

Display all databases accessible to the user:

Code
SHOW DATABASES;

Conclusion

You have successfully installed MariaDB on FreeBSD 14.0, secured the server, and configured authentication for database users. MariaDB can now serve as a secure and high-performance database backend for your applications. To make it accessible remotely, adjust the bind address in the configuration file from localhost to 0.0.0.0 or your network’s private IP.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Databases
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren