In the event that you are using the Linux-based operating system CentOS or any of its derivatives, you can optionally compile MariaDB from source code. This is useful in cases where you want use a more advanced release than the one that's available in the official repositories, or when you want to enable certain feature that are not otherwise accessible.
Installing Build Dependencies
Before you start building MariaDB, you first need to install the build dependencies required to run the compile. CentOS provides a tool for installing build dependencies. The
yum-builddep utility reads a package and generates a list of the packages required to build from source, then calls YUM to install them for you. In the event that this utility is not available on your system, you can install it through the
yum-utils package. Once you have it, install the MariaDB build dependencies.
# yum-builddep mariadb-server
Running this command installs many of the build dependencies, but it doesn't install all of them. Not all the required packages are noted and it's run against the official CentOS package of MariaDB, not necessarily the version that you want to install. Use YUM to install the remaining packages.
# yum install git \ gcc \ gcc-c++ \ bison \ libxml2-devel \ libevent-devel \ rpm-build
In addition to these, you also need to install
openssl, depending on the TLS implementation you want to use.
For more information on dependencies, see Linux Build Environment.
Once you have the base dependencies installed, you can retrieve the source code and start building MariaDB. The source code is available on GitHub. Use the
--branch option to specify the particular version of MariaDB you want to build.
$ git clone --branch 10.3 https://github.com/MariaDB/server.git
With the source repository cloned onto your system, you can start building MariaDB. Run CMake to read MariaDB for the build,
$ cmake -DRPM=centos7 server/
Once CMake readies the relevant Makefile for your system, use Make to build MariaDB.
$ make package
This generates an RPM file, which you can then install on your system or copy over to install on other CentOS hosts.
In the event that you miss a package while installing build dependencies, CMake may continue to fail after you install the necessary packages. If this happens to you, delete the CMake cache then run the above the command again:
$ rm CMakeCache.txt
When CMake runs through the tests again, it should now find the packages it needs, instead of the cache telling it they're unavailable.