DEV Community

Vincent Milum Jr
Vincent Milum Jr

Posted on

Compiling MariaDB from Source - On FreeBSD

This is part of a series of articles I'm writing on how to accomplish common tasks in FreeBSD. Every day, I see new tutorials on "How To Do (THING) on Linux in 20 easy steps!" - so here I am, matching each of those articles, but from the perspective of showing the amazing simplicity of FreeBSD instead.

Alt Text

Compiling MariaDB from Source

On many other platforms, they'll start out with a complicated set of steps to create the build environment, setup the compiler and tool chain, then download and extract the source code before even getting to the compilation. This is all 100% automated in the FreeBSD world!

1) Enter the directory for the MariaDB Port

cd /usr/ports/databases/mariadb105-server/
Enter fullscreen mode Exit fullscreen mode

2) Download, configure, and compile MariaDB (yes, all in one command)

make
Enter fullscreen mode Exit fullscreen mode

3) Install your now compiled MariaDB binaries

make install
Enter fullscreen mode Exit fullscreen mode

And just like that, MariaDB is not only compiled, but it is also installed! What about all of the compiler tools required? What about runtime dependencies? All of that is taken care of for us automatically via the FreeBSD Ports collection!

Alternatively, if you want to install MariaDB from pre-built binary packages, that option is also available. Simple replace steps 1-3 with with the following:

pkg install -y mariadb105-server
Enter fullscreen mode Exit fullscreen mode

But wait, there are actually two more important steps after this... because we need to actually RUN our server, not just compile and install it!

NOTE: For the time being, MariaDB still uses the "mysql-server" service on FreeBSD, as it has yet to be renamed.

4) Enable the MariaDB service to start at boot time

service mysql-server enable
Enter fullscreen mode Exit fullscreen mode

5) Start the MariaDB service without first rebooting

service mysql-server start
Enter fullscreen mode Exit fullscreen mode

But wait, what about the utility to create the initial MariaDB database? That too is taken care of for us automatically on first run! Everything is designed from the ground up for easy sysadmin automation.

Recap

So, let's recap. Step one, draw a couple circle. Step two, let FreeBSD draw the rest of the owl! ;)

Top comments (0)