DEV Community

Arunesh Choudhary
Arunesh Choudhary

Posted on • Updated on

Install MariaDB from Source Code on Ubuntu

System Information:

Distributor ID:     Ubuntu
Description:        Ubuntu 22.04.1 LTS
Release:            22.04
Codename:           jammy
Enter fullscreen mode Exit fullscreen mode

Get the source code

Fork the repo

git@github.com:AgeDB-Enterprise/maria-server.git
Enter fullscreen mode Exit fullscreen mode

Keep the same name "maria-server" for your local repository.

Let's setup project

Create a directory for the mariaDB Project

mkdir mariaDB
cd mariaDB
Enter fullscreen mode Exit fullscreen mode

Clone your repo to your machine.

mariaDB $ git@github.com:arun-esh/maria-server.git
Enter fullscreen mode Exit fullscreen mode

Build the Server

Optional if cMake is not installed

sudo apt-get install build-essential libncurses5-dev gnutls-dev bison zlib1g-dev ccache libssl-dev -y

# In case, cmake is not installed on the machine. It was the case for me.
# Get cmake
# Downloaded under ~/
wget https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2.tar.gz


tar -xvf cmake-3.25.2.tar.gz

cd cmake-3.25.2
~/cmake-3.25.2 $ ./bootstrap
~/cmake-3.25.2 $  make
~/cmake-3.25.2 $  sudo make install

Enter fullscreen mode Exit fullscreen mode

Configure the build

mariaDB $ mkdir build-mariadb-server-debug
mariaDB $ cd build-mariadb-server-debug

# configure mariaDB
build-mariadb-server-debug $ cmake ../maria-server -DCMAKE_BUILD_TYPE=Debug
Enter fullscreen mode Exit fullscreen mode

Compile

build-mariadb-server-debug $ cmake --build . --parallel 5
Enter fullscreen mode Exit fullscreen mode

Starting MariaDB after build

# Create a directory 
mkdir data-dir

# create ~/mariadb.cnf
# The MariaDB server group

[mariadb]
datadir           = ~/mariaDB/data-dir
# path to source dir + sql/share
lc_messages_dir   = source/sql/share



# Now that you have created your own config file you can call it with flag `--defaults-file` while installing the system tables. To install the system tables call following from the build folder:
./scripts/mariadb-install-db --srcdir=../maria-server --defaults-file=~/mariadb.cnf

# Run the DB Server
sql/mariadbd --defaults-file=~/mariadb.cnf

# Run client command line
client/mariadb
Enter fullscreen mode Exit fullscreen mode

Top comments (0)