MariaDB Server is hosted on GitHub. The official repository can be found at https://github.com/MariaDB/server.
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
cmake, so you will need to have git installed and cmake.
Get the source code
The current development version of MariaDB is 10.3. 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 https://github.com/MariaDB/server
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_CXX_FLAGS. All cmake configuration options for MariaDB can be displayed with:
cmake . -LH
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
git clean -dffx git reset --hard HEAD
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
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
apt-get install ninja-build
If you have successfully installed build system with
ninja --version you will obtain installed version.
Make sure that you cleaned old object files and run again
cmake but this time with
cmake . -DCMAKE_BUILD_TYPE=Debug -G Ninja
Now you are ready to compile server with
When running make, cmake executes the script which can be found in cmake/build_configuration/mysql_release.cmake.
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/clients/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
or to run only
cd mysql-test ./mtr --suite=unit --mem --parallel=5
Each of the above is run from source directory.
There are lots of useful flags for
--parallel=#number-of-parallel-taskswill run multiple tests in parallel, thus speeding up tests. The process can easily take over an hour, even if parallelization is used.
--memis used to force the tests to be run on a virtual ramdisk. This will speed things up as long as RAM is sufficient.
--forceis used to continue to run the suit after failure.
--max-test-failis 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
--embeddedis used to run with the embedded server.
--helpis 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 [mariadb] 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 --user=$LOGNAME
After that you can start
cd sql ./mysqld
After starting up
mysqld you can launch the client as root:
cd ../client ./mysql