Get the code, build it, test it

MariaDB Server is hosted on GitHub. The official repository can be found at


For getting started as a developer and to make your debugging process easier, make sure that your hardware has at least 2GB RAM, 2GB HD and at least 4 cores. We are working with git and cmake, so you will need to have git installed and cmake.

Get the source code

The current development version of MariaDB is 10.4.  On a Debian based distribution it is recommended that everything you do with development you do as a regular user, not as a super user.

The recommended way to get the source is to clone it.

git clone

Build the server

Before you can build the server, you must install build dependencies. On a Debian based distribution:

apt-get build-dep mysql-server
apt-get install libgnutls28-dev # This may or may-not be already installed

Configure the build

MariaDB uses cmake to generate Makefiles used to compile the server.

To check if cmake is installed run cmake --version. Cmake has a CMAKE_BUILD_TYPE option for predefined build types, which affects optimization and whether the result of the build can be debugged. One of them is a Debug type, for which optimizations are off and debug info is generated. This option is used for creating the trace files which are useful if mysqld is crashing. Running without specifying CMAKE_BUILD_TYPE uses default the C and C++ compilers described with CMAKE_C_FLAGS and CMAKE_CXX_FLAGS. All cmake configuration options for MariaDB can be displayed with:

cmake . -LH

where L stands for short form, LH short form plus description, LA lists internal and advanced ones options. For more options see cmake documentation.

Before you configure build make sure to clean out old object files and cached information before reconfiguring and rebuilding:

make clean

rm CMakeCache.txt

or (prefered):

git clean -dffx

git reset --hard HEAD

git submodule update

The last command is needed because fresh git clonedoesn’t automatically clone everything (examples are modules libmariadb and storage/rocksdb/rocksdb folder which is upstream submodule). After git submodule update run again git status. To configure a Debug build, useful for development, go to the base folder where you’ve cloned the MariaDB source tree and run:

cmake . -DCMAKE_BUILD_TYPE=Debug

Debugging options allow the use of the DBUG package created by Fred Fish.

CMake will now check to see which libraries are available, which compiler is installed and if everything checks out, it will finish with a “Configure successful” message. If there are failures, check to see which libraries you need to install. You probably need to install the development versions of them.

Configuration with CMake produces files under the CMakeFiles directory:
CMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log.

After the initial configuration has been performed you can add more options to cmake. Options are remembered in the CMake cache (the CMakeCache.txt file in the build directory).
If the configuring doesn’t succeed because an error occurs, for example you obtain error not found variable LZ4_LIBS, run the additional option -DWITHOUT_MROONGA=True. It will also work if instead of True you use 1.

Build with embedded server is not set by default in the build since it doubles the
compilation time. In order to use it, compile the server with cmake . -DWITH_EMBEDDED_SERVER=1.

As an alternative you can also use ninja build system in order to run builds faster. To do so make sure you have installed ninja.

apt-get install ninja-build

If you have successfully installed build system withninja --version you will obtain installed version.

Make sure that you cleaned old object files and run again cmake but this time with Ninja flag and with prefix -G.

cmake . -DCMAKE_BUILD_TYPE=Debug -G Ninja

Now you are ready to compile server with make orninja, or to be independent of the build system invoke cmake --build . inside the build directory.

For the faster build you can exclude storage engines that you don’t need in your development. Here is an example of excluding some of storage engines


Another example of disabling all engines plus other cmake configuration options for faster build


To see the full list of options used by cmake or to change them through GUI, from base folder run ccmake .(you will have to install cmake-curses-gui). Optionally, you can see the list of all parameters from build directory in CMakeCache.txtand change them.


When running make, cmake executes the script which can be found in cmake/build_configuration/mysql_release.cmake.

 make -j5

Substitute 5 with the number of cores you have available for faster builds.

At the end, executable files are obtained as a standalone layout (.tar.gz/.zip packages), which will be used for the server (server/sql/mysqld) or clients (server/client/mysql).

If you use ninja build system compile it with


Testing the server

Now that the server is built, we should test that everything is working properly.

To find out if your mysqld binary has debugging support, run from the server/sql directory ./mysqld -V on the command line. If the version number ends in -debug then your mysqld binary was compiled with debugging support.

MariaDB has a testing framework defined in mysql-test folder. To run all tests:

 cd mysql-test
./mtr --parallel=5 --mem --force --max-test-fail=0

Note: if you are using MacOS omit the `–mem` flag. To run only unit tests:

cd mysql-test

./mtr --suite=unit --mem --parallel=5

Each of the above is run from source directory. mysql-test-run uses his own --defaults-file overriding any default one.

You can see logs for your test in


There are lots of useful flags for mtr.

  • --parallel=#number-of-parallel-tasks will run multiple tests in parallel, thus speeding up tests. The process can easily take over an hour, even if parallelization is used.
  • --mem is used to force the tests to be run on a virtual ramdisk. This will speed things up as long as RAM is sufficient.
  • --force is used to continue to run the suit after failure.
  • --max-test-fail is used to limit the number of test failures before aborting the current test run. Defaults to 10, set to 0 for no limit. Set it’s default with MTR_MAX_TEST_FAIL.
  • --embedded is used to run with the embedded server.
  • --big-test(or just --big) is used to run the big tests (tests which can use log memory and/or disk. In tests these tests have --source include/ If you want only to run big test use the flag two times --big --big.
  • --help is used to show options to control what engine/variation to run.

Starting mysqld after build

You can run mysqld directly from the build directory (without executing sudo make install).

If you are running MariaDB for first time you will need to run mysql_install_db to install the needed system tables. But before that create a directory for your data (this directory will be used for the datadir system variable in the config file). Copy following in  ~/.my.cnf file.

# The MariaDB server group

datadir           = path/to/your/data/dir
tmpdir            = path/to/your/tmp/dir
# path to source dir + sql/share
lc_messages_dir   = source/sql/share
max-connections   = 20
lc-messages       = en_us

If you need to change something, read more about setting mysqld configuration files and groups.

Now you can go to the source directory and execute the following:

./scripts/mysql_install_db  --srcdir=. --datadir=/path/to/data/dir

You are to create your own config file and call it with flag `–defaults-file` while installing the system tables. Create a new file ~/my-config.cnf and add the following as minimal working example (MWE):

# The MariaDB server group 

datadir           = path/to/your/data/dir 
# path to source dir + sql/share 
lc_messages_dir   = source/sql/share 
max-connections   = 20 
lc-messages       = en_us

Now to install the system tables call following from the base folder:

./scripts/mysql_install_db --srcdir=. --defaults-file=~/my-config.cnf

After that you can start mysqld, which by default looks for option file. If --defaults-file is given mysqld will read only from this file. Navigate to your base folder and run

cd sql


After starting up mysqld you can launch the client as root:

cd ../client

./mysql -u root

What is next?

As a new contributor we encourage you to look more in beginner friendly jira tasks where you can find appropriate task that you can work on. In order to work on this task just write a comment in the ticket, stating that you re interested in working on it.

Read more about generic build instructions,  running MariaDB from build directory, starting and stopping MariaDB automatically.

See also