to install the MariaDB database manager and to validate which components are available for the MariaDB databases we will execute the following command. We can see the various options available.
ls -al /usr/ports/databases/ | grep mariadb
In this case, we will install the mariadb102 package by executing the following command:
pkg install mariadb102-server mariadb102-client php71-mysqli
Now, we will enable the MariaDB server in FreeBSD and initiate the daemon of the database by running the following commands:
sysrc mysql_enable="yes" service mysql-server start
Now we will ensure the installation of MariaDB by executing the mysql_secure_installation line in the following way:
That command will initiate a series of questions that we must define based on the current needs:
By default, the MariaDB daemon listens for network connections outside localhost on port 3306 / TCP.
We can execute the commands netstat, lsof or sockstat to obtain the status of the MariaDB socket, since this configuration is dangerous and exposes the service to external network attacks affecting the data hosted there.
lsof -i4 -i6 sockstat -4 -6
If isn’t necessary the remote access to MariaDB, we must make sure that the daemon of MariaDB only listens to the localhost, for it we execute the following command.
Then, restart the MariaDB service to apply the changes.
sysrc mysql_args="--bind-address=127.0.0.1" service mysql-server restart
Test MariaDB on FreeBSD
Finally to test the connectivity to the database we will execute the following command.:
mysql -u root -p -e "show databases"
There we will enter the password that has been assigned, and this will be the result: