Building MariaDB on Ubuntu

In the event that you are using the Linux-based operating system Ubuntu or any of its derivatives and would like to compile MariaDB from source code, you can do so using the MariaDB source repository for the release that interests you.

Before you begin, install the software-properties-common, devscripts and equivs packages.

$ sudo apt-get install software-properties-common \
      devscripts \

Installing Build Dependencies

MariaDB requires a number of packages to compile from source. Fortunately, you can use the MariaDB repositories to retrieve the necessary code for the version you want. Use the Repository Configuration tool to determine how to set up the MariaDB repository for your release of Ubuntu, the version of MariaDB that you want to install, and the mirror that you want to use.

First add the authentication key for the repository, then add the repository.

$ sudo apt-key adv --recv-keys \
      --keyserver hkp:// \
$ sudo add-apt-repository --update --yes --enable-source \
       'deb [arch=amd64] '$(lsb_release -sc)' main'

Once the repository is set up, you can use apt-get to retrieve the build dependencies. MariaDB packages supplied by Ubuntu and packages supplied by the MariaDB repository have the same base name of mariadb-server. You need to specify the specific version you want to retrieve.

$ sudo apt-get build-dep mariadb-10.3

Building MariaDB

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

The source code includes scripts to install the remaining build dependencies. For Ubuntu, they're located in the debian/ directory. Navigate into the repository and run the script. Then use

$ cd server/
$ ./debian/

Further Dependecies

In the event that there are still build dependencies that are not satisfied, use mk-build-deps to generate a build dependency deb to use in installing the remaining packages.

$ mk-build-deps debian/control
$ apt-get install ./mariadb-*build-deps_*.deb

Then, call the script again to build MariaDB.

$ ./debian/

After Building

After building the packages, it is a good idea to put them in a repository. See the Creating a Debian Repository page for instructions.


Comments loading...