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.
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
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:
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:
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.