In this guide we will learn how to install and configure MariaDB on FreeBSD.
MariaDB is an open-source one of the most popular relational database management system (RDBMS) that is a highly compatible drop-in replacement of MySQL. It is built upon the values of performance, stability, and openness, and MariaDB Foundation ensures contributions will be accepted on technical merit.
MariaDB was developed as a software fork of MySQL in 2009 in response to Oracle’s acquisition of MySQL. MariaDB intends to remain free and open-source software under the GNU General Public License. It is part of most cloud offerings and the default in most Linux distributions.
Updated for 2026. This guide was originally written for FreeBSD 13 and MariaDB 10.5, both of which have since reached end of life — FreeBSD 13 is no longer a supported branch, and MariaDB 10.5 stopped receiving fixes in June 2025. The steps below now target the supported FreeBSD 14.x and 15.x branches and a current MariaDB LTS release. The commands themselves are unchanged in shape, so they still work on older systems; only the package names and versions differ.
Related Posts:
- How to Set Up MariaDB in Kubernetes using Helm and Kustomize
- How to install and Configure Mariadb 10 in OpenSUSE Leap 15.3
- How to install and Configure Mariadb 10 in Debian 11
- How to install and Configure Mariadb 10 in Ubuntu 20.04
- How to install and Configure Mariadb 10 in Rocky Linux/Alma Linux 8
- How to Install and Enable Sudo on FreeBSD
Prerequisites:
To follow along, ensure you have:
- An up to date FreeBSD server/workstation — FreeBSD 14.x or 15.x, since FreeBSD 13 is end of life
- Root access to the server or a user with sudo access
- Access to the internet from the server
Ensure that the system is up to date
Before proceeding let us ensure that the FreeBSD server is up to date. We will use the pkg command as a root user if you don’t have sudo installed:
| |
pkg update only refreshes the local copy of the package catalogue; pkg upgrade is what actually installs the newer packages.
Installing MariaDB in FreeBSD
MariaDB can be found in the default FreeBSD repos. To search the name of the package, use this command:
| |
The exact point releases you see will differ as the ports tree moves — what matters is the major version you pick. FreeBSD ships several in parallel, and the port name encodes the version with the dot removed (mariadb114-server is MariaDB 11.4). Only the LTS releases are worth running on a server:
| Port | MariaDB | Community support until |
|---|---|---|
mariadb1011-server | 10.11 LTS | February 2028 |
mariadb114-server | 11.4 LTS | May 2029 |
mariadb118-server | 11.8 LTS | June 2028 |
mariadb123-server | 12.3 LTS | June 2029 |
The
mariadb105-*packages this guide originally used are gone: MariaDB 10.5 reached end of life in June 2025 and 10.6 followed in July 2026. If you are still running either, plan an upgrade — they no longer get security fixes.
For a new install, 11.4 LTS is the safe default: it is well past its initial release, widely deployed, and supported into 2029. Install the server and the matching client:
| |
Stick to one major version — the MariaDB server ports conflict with each other, so pkg will refuse to install mariadb114-server alongside, say, mariadb1011-server.
Starting and enabling MariaDB
MariaDB will not be started by default. The FreeBSD ports still name the rc script mysql-server and the rc variable mysql_enable regardless of the MariaDB version you installed, so enable start on boot first:
| |
Then start the service:
| |
Confirm that the service is up and running by checking its status
| |
Configuring MariaDB
For new MariaDB installations, the next step is to run the included security script. This script changes some of the less secure default options. We will use it to block remote root logins and to remove unused database users.
Run the security script:
| |
Since MariaDB 10.5, the client tools have been renamed to a
mariadb-*prefix —mariadb-secure-installation,mariadb-admin,mariadb-dump, and themariadbclient itself. The oldmysql_secure_installation,mysqladmin, andmysqlnames still exist as symlinks for compatibility, so both work today, but themariadb-*names are the ones to use going forward.
This will take you through a series of prompts where you can make some changes to your MariaDB installation’s security options. The first prompt asks for the current database root password. A fresh install from ports does not have one, so press ENTER to indicate “none”.
The next prompt asks whether you want to switch to unix_socket authentication. Answer Y. This ties the database root user to the operating system’s root account: anyone already logged in as root on the box can run mariadb with no password, and nobody else can log in as database root at all, password or not. It removes the password as something to guess, leak, or leave in a script.
You will then be asked whether to change the root password. With unix_socket authentication enabled this is optional — you can safely answer n and rely on socket auth alone. Set one only if you need to reach the root account some other way; if you do, choose a strong password and store it in a password manager.
From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MariaDB immediately respects the changes you have made.
This is my server’s output (taken on a run where a root password was also set):
| |
Testing MariaDB
Now that MariaDB is all set up and is running, we need to confirm that it can accept connections.
To test, connect to MariaDB with the root user - mariadb -h 127.0.0.1 -u root -p
Output:
| |
Note that this connects over TCP to 127.0.0.1, which is why it prompts for a password. If you enabled unix_socket authentication and did not set a root password, connect over the socket instead — as the system root user, plain mariadb gets you in with no password.
Check the MariaDB version:
| |
For an additional check, you can try connecting to the database using the mariadb-admin tool (formerly mysqladmin), which is a client that lets you run administrative commands. For example, this command says to connect to MariaDB as root and return the version using the Unix socket:
| |
You should receive output similar to this:
| |
This means that MariaDB is up and running and that your user is able to authenticate successfully.
Conclusion
In this guide you installed MariaDB to act as an SQL server. During the installation process you also secured the server.