Install MariaDB 10.5 on FreeBSD 13

|
Last Updated:
|
|

In this tutorial, you will how to install MariaDB 10.5 on FreeBSD 13. “MariaDB 10.5 is the current stable series of MariaDB. It is an evolution of MariaDB 10.4 with several entirely new features not found anywhere else and with backported and reimplemented features from MySQL”.

Are you still running FreeBSD 12? Hold on, FreeBSD 13.0 has been released and you can now backup your data and upgrade your FreeBSD 12 box to FreeBSD 13.

freebsd-version
13.0-RELEASE

Follow the link below to upgrade it;

Upgrade FreeBSD 12 to 13

Installing MariaDB 10.x on FreeBSD 13

Run System Update

Assuming that you are installing MariaDB 10.5 on a newly installed FreeBSD 13, update and FreeBSD package catalogue.

pkg update
pkg upgrade

Install MariaDB 10.5

The FreeBSD 13 package catalogue provides the latest stable release versions of MariaDB, which is MariaDB 10.5.9 as of this writing.

pkg search mariadb
mariadb-connector-c-3.1.10     MariaDB database connector for C
mariadb-connector-odbc-3.1.11  MariaDB database connector for odbc
mariadb103-client-10.3.28_1    Multithreaded SQL database (client)
mariadb103-server-10.3.28      Multithreaded SQL database (server)
mariadb104-client-10.4.18      Multithreaded SQL database (client)
mariadb104-server-10.4.18      Multithreaded SQL database (server)
mariadb105-client-10.5.9       Multithreaded SQL database (client)
mariadb105-server-10.5.9       Multithreaded SQL database (server)

Therefore, to install MariaDB 10.5, simply execute the command below;

pkg install mariadb105-server mariadb105-client
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 14 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	boost-libs: 1.72.0_3
	galera26: 26.4.6_1
	icu: 68.2,1
	libedit: 3.1.20210216,1
	libiconv: 1.16
	liblz4: 1.9.3,1
	libxml2: 2.9.10_3
	mariadb105-client: 10.5.9
	mariadb105-server: 10.5.9
	pcre2: 10.36
	rsync: 3.2.3
	unixODBC: 2.3.9
	xxhash: 0.8.0
	zstd: 1.4.8

Number of packages to be installed: 14

The process will require 473 MiB more space.
57 MiB to be downloaded.

Proceed with this action? [y/N]: y

Running MariaDB 10.5 on FreeBSD 13

Once the installation is installed, you can start MariaDB on FreeBSD 13;

service mysql-server onestart

Checking the status of MariaDB service on FreeBSD 13

service mysql-server onestatus
mysql is running as pid 1269.

You can enable MariaDB to run on system boot using the command below;

sysrc mysql_enable=yes

Or simply run;

service mysql-server enable

You would then be able to manage MariaDB service as follows;

To start MariaDB service;

service mysql-server start

To stop the service;

service mysql-server stop

Disable the service from running on system boot;

service mysql-server disable

Restart MariaDB 10.5 on FreeBSD 13

service mysql-server restart

Check Status;

service mysql-server status

Securing MariaDB 10.5 on FreeBSD 13

MariaDB comes with a default security script, mysql_secure_installation that is used to improve the security of MariaDB installation by:

  • Setting the password for root accounts (if need be).
  • Disabling remote root login to the databases.
  • Removing anonymous-user accounts.
  • Removing the test database, which by default can be accessed by anonymous users.

Simply run the command below to launch the script.

mysql_secure_installation

MariaDB 10.5 Authentication

The new installations of MariaDB have two secure accounts are created during the installation. The accounts are root@localhost and mysql@localhost. Both accounts uses either of the unix_socket and the mysql_native_password authentication plugins.

unix_socket authentication plugin allows a system root user or a user with sudo rights to login as root@locahost to MariaDB database without a password. You can even login as mysql user.

With unix_socket authentication plugin, while being a root user, or user with sudo rights you can simply login by running either of the commands below;

mysql

or

mysql -u root

Even if you run, mysql -u root -p, and press ENTER for blank password, you will still login.

As a user with sudo rights, prefix the commands above with sudo.

If sudo is not installed, you can install it by running the command below;

pkg install sudo

Read more about MariaDB authentication plugins on MariaDB Knowledge base.

Enable MariaDB password Authentication on FreeBSD 13

The mysql_native_password plugin is used as a failover for the unix_socket plugin. However, the account has an invalid password. To enable password authentication, you need to login to MariaDB as root user as shown above and set the password.

mysql
set password = password("P@sSw0Rd123");
flush privileges;
quit

This re-enables the MariaDB password authentication and hence, you can now login as non root or non sudo user.

mysql -u root -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.5.9-MariaDB FreeBSD Ports

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]>

Similarly, you can login as mysql user;

sudo -u mysql mysql

Set Native Password Authentication Method as Default

To completely disable unix_socket authentication plugin and instead use the msqyl_native_password authentication method, simply login to MariaDB and change the authentication plugin for root user.

mysql
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("MyPQQSSword");
flush privileges;
quit

Next time you try to login without specifying the password, login will fail.

sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

You can go ahead and perform your database tasks using MariaDB 10.5 on FreeBSD 13.

You can check our other guides on MariaDB/MySQL installations by following the links below;

Install MariaDB 10 on Debian 10 Buster

Install MariaDB 10.4 on Ubuntu 18.04/Debian 9

Install MariaDB 10.3 on CentOS 7

Install MariaDB 10.3 on Fedora 30

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment