Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to install MariaDB in FreeBSD

April 26, 2017 by Albert Valbuena

MariaDB is a derivative from the world-famous enterprise class MySQL database. The MySQL founder is Michael Widenius, also known as Monty. He created the project, it worked out for some time, it caught Sun’s attention and they bought it. Then Oracle bought Sun and knowing Larry everyone left running without looking what was left behind. Don’t get me wrong. I admire Larry Ellison for very good reasons. But I can recognize when something is wrong and when everybody runs out of a company after an acquisition because they are scared of their practices and specially from the new owner’s ways, there is definitely something very wrong about it.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

Anyway. MySQL is still being developed by Oracle but there are alternatives as MariaDB. Just before the Oracle’s hecatomb Mr Widenius left Sun and founded MariaDB for the very best reasons. There is another fork from MySQL called PerconaDB. You can install any database of those three.

Before installing the database we will look for the right package to install. We will use the pkg utility and this time instead of appending install “this_package”, we will tell it “search this_package” like so:

As you can see there are a few packages and three different versions. You can google for the adequate package you want to if you need specific features. That said version 101 is the equivalent of 10.1 and this is the latest one. And obviously the latest one has all the new features and the old ones. We will install this last one by typing this:

sudo pkg install mariadb101-server mariadb101-client

Now we have to add the mysql service at the boot time so when we start up the server the database starts up. And yes, the syntax is right. Percona and MariaDB still use mysql as a command as the original MySQL does.

sudo vi /etc/rc.conf

mysql_enable="YES"

You can also add this line using echo as follows without the need of using vi. Mind we check the file has been modified and the line written by using the cat command.

The file should now look something similar to this:


Launch MySQL

sudo service mysql-server onestart

A few things happening. Don’t be scared. The MariaDB database is “bootstrapping” itself.

Install MySQL securely

Start by typing:

sudo mysql_secure_installation

You will have to type the command above in order to install MariaDB, PerconaDB or MySQL in a secure manner. In doing this you will set the inner root password for the database (please choose a strong one if you are on production), it will also remove users that are doing nothing after the installation etc. This is not something to do just for install time. Any database without a username is doing nothing there sitting. Any user without a database associated is doing nothing in your server. Nothing but being an entry point for a malicious actor or something simpler but even more annoying, error messages because of something weird happening. Administrators do not only administer. They also keep things clean and in good shape.

In the next page you will see the install messages appearing. Just type enter at the beginning because you still haven’t set a root password for the database. Then just type enter to select the default (secure) installation.

You can now start using your MariaDB database. Remember this is “simple” installation. If you want to secure your database remember the applications talking to it also have to be secured. Don’t stop here and keep on looking for valuable information.

Update 05-2020: For an automatic install you can use this script from the Adminbyaccident’s Github repository.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

 

Filed Under: How To's

Recent Posts

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall

Archives

  • November 2024
  • October 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in