DEV Community

Talha Munir 🇵🇸
Talha Munir 🇵🇸

Posted on

Installing maria DB in Ubuntu 22.04 part 1

Maria db is a popular fork of MySQL. It is an open source relational database management system. It is a replacement of MYSQL database which provides enhanced performance and efficient security features. It provides support for many SQL commands and datatypes. It also enables developers to extend its functionality by contributing to it. It provides high availability, clustering support and cache mechanisms. It is mostly used in industries that include finance, healthcare and e-commerce.

Prerequisite:

1.Ubuntu 22.04 must be installed in the Virtual Machine or dual boot alongside windows.
2.You should have ample space in your software.
You should have already installed git. If not you can take help from here "Install Git".
3.Cmake should be installed in your linux system software. If not you can take help from here Install CMake.

I have used ubuntu on a virtual machine. Below is a step-by-step guide for installing Maria DB on Linux from the source.

Building from source

Managing Configurations:

At the start we have to create a configuration file in this path "/etc/apt/sources.list.d/mariadb.list". Use following command to do that:

sudo gedit /etc/apt/sources.list.d/mariadb.list
Enter fullscreen mode Exit fullscreen mode

After that save the following configurations into the file /etc/apt/sources.list.d/mariadb.list

# Retrieved from: https://mariadb.org/download/?t=repo-config

# MariaDB 11.0 [RC] repository list - created 2023-02-24 18:43 UTC
# https://mariadb.org/download/
deb https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main
deb-src https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main
deb https://mirror.its.dal.ca/mariadb/repo/11.0/ubuntu jammy main/debug
Enter fullscreen mode Exit fullscreen mode

Installing dependencies:

sudo apt-get install software-properties-common \
      devscripts \
      equivs \
      curl \
      git
sudo apt-get build-dep mariadb-server
Enter fullscreen mode Exit fullscreen mode

Next step is to import the repository key and update apt. You should not get any error from the mariadb repository server.

sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Incase you didn't receive any error in the previous steps move to the build process.

Build

We will make 3 working directories. maria-server which will be the source directory. maria-server-build would be a build directory and maria-server-data would be data directory. You can allocate your own names but make sure to use them correctly. Let's create them inside the home directory.

cd ~

Fork and then clone the forked repository:
(In my case)

git clone https://github.com/TalhaMunir-JD/maria-server.git
Create the build and data directory in home directory:

mkdir ~/maria-server-build
mkdir ~/maria-server-data
Enter fullscreen mode Exit fullscreen mode

Above 2 commands will create maria-server-build and maria-server-data directory in home.

Execute the following commands to start building. Make sure to use correct directory in each command:

cd ~/maria-server-build
cmake ~/maria-server/ -DCMAKE_BUILD_TYPE=Debug
cmake --build ./ -j8
Enter fullscreen mode Exit fullscreen mode

Above command will start the installation process.
Image description

Configure:

Before going forward you should have maria db installed without any error from cmake.

Copy the following configurations into the file ~/.my.cnf. Set the absolute path to your data and build directory in the datadirand language entry in the below commands before saving:

# Example MariadB config file.
# You can copy this to one of:
# /etc/my.cnf to set global options,
# /mysql-data-dir/my.cnf to get server specific options or
# ~/my.cnf for user specific options.
#
# One can use all long options that the program supports.
# Run the program with --help to get a list of available options

# This will be passed to all MariaDB clients
[client]
#password=my_password
#port=3306
#socket=/tmp/mysql.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# The mariadb server  (both [mysqld] and [mariadb] works here)
[mariadb]
#port=3306
#socket=/tmp/mysql.sock

# The following three entries caused mysqld 10.0.1-MariaDB (and possibly other versions) to abort...
# skip-locking
# set-variable  = key_buffer=16M

loose-innodb_data_file_path = ibdata1:1000M
loose-mutex-deadlock-detector
gdb

######### Fix the two following paths

# Where you want to have your database
datadir={absolute-path-to-your-data-directory}

# Where you have your mysql/MariaDB source + sql/share/english
language={absolute-path-to-your-build-directory}/sql/share/english

########## One can also have a different path for different versions, to simplify development.

[mariadb-10.1]
lc-messages-dir=/my/maria-10.1/sql/share

[mariadb-10.2]
lc-messages-dir=/my/maria-10.2/sql/share

[mysqldump]
quick
set-variable = max_allowed_packet=16M

[mysql]
no-auto-rehash

[myisamchk]
set-variable= key_buffer=128M
Enter fullscreen mode Exit fullscreen mode

After above process initialize the data files in the data directory:

cd ~/maria-server-build
./scripts/mariadb-install-db --srcdir={absolute-path-to-your-source-directory} --user=$LOGNAME
Enter fullscreen mode Exit fullscreen mode

Above command will show the below messages:
Image description

Run:

check the install of maria db by executing the below command:
./sql/mariadbd

You will se something similar to this in the terminal:

Image description

Image description

References:

Following are some of the references that helped me in installation of maria db:
1.https://github.com/AgeDB-Enterprise/maria-server#readme2
2.https://mariadb.com/kb/en/generic-build-instructions/

Top comments (0)