Tutorial Install Mutiple MariaDB Versions on Linux Ubuntu v24.04


Download MariaDB for Linux on https://mariadb.org/download

In this case I use Linux Ubuntu v24.04

I already download 4 files :

mariadb-10.6.25-linux-systemd-x86_64.tar.gz

mariadb-10.11.16-linux-systemd-x86_64.tar.gz

mariadb-11.4.10-linux-systemd-x86_64.tar.gz

mariadb-11.8.6-linux-systemd-x86_64.tar.gz


Step-1 :   Create directory

$ sudo mkdir -p /usr/local/mariadb

and then

$ cd /usr/local/mariadb


Step-2 :   Move files above into /usr/local/mariadb

$ sudo mv /home/ubuntu/Downloads/mariadb-10.6.25-linux-systemd-x86_64.tar.gz .

$ sudo mv /home/ubuntu/Downloads/mariadb-10.11.16-linux-systemd-x86_64.tar.gz .

$ sudo mv /home/ubuntu/Downloads/mariadb-11.4.10-linux-systemd-x86_64.tar.gz .

$ sudo mv /home/ubuntu/Downloads/mariadb-11.8.6-linux-systemd-x86_64.tar.gz .


Step-3 :   Extract file .tar.gz

$ sudo tar xzf ./mariadb-10.6.25-linux-systemd-x86_64.tar.gz

$ sudo rm -rf ./mariadb-10.6.25-linux-systemd-x86_64.tar.gz

$ sudo mv mariadb-10.6.25-linux-systemd-x86_64 mariadb-10.06

$ cd mariadb-10.06


Step-4 :   Create directory "data"

$ sudo mkdir -p data


Step-5 :   Create file configuration my.cnf

$ sudo touch my.cnf

$ sudo nano my.cnf


Paste these into my.cnf :

---   ---   ---

[mysqld]

datadir=/usr/local/mariadb/mariadb-10.06/data

port=3301

bind-address=0.0.0.0


[client]

port=3301

plugin-dir=/usr/local/mariadb/mariadb-10.06/lib/plugin

---   ---   ---

Don't forget save my.cnf


Step-6 :   Create user group on Linux

$ sudo groupadd mysql


Step-7 :   Create user and add to user group

$ sudo useradd -g mysql mysql


Step-8 :   Set ownership role on Linux

$ sudo chown -R mysql .

$ sudo chgrp -R mysql .


Step-9 :   Install MariaDB

$ sudo scripts/mysql_install_db --user=mysql


Step-10 :   Update ownership role, again.

$ sudo chown -R root .

$ sudo chown -R mysql data


Step-11 :   Check existing service system on Linux

$ sudo ls -al /etc/systemd/system | grep "mariadb"


Step-12 :   Create service system on Linux

$ sudo nano /etc/systemd/system/mariadb@10.06.service


Paste these into mariadb@10.06.service :

---   ---   ---

[Unit]

Description=MariaDB 10.06 database server (Custom Instance)

After=network.target


[Service]

Type=simple

User=mysql

Group=mysql


# Adjust these paths to your specific manual install

ExecStart=/usr/local/mariadb/mariadb-10.06/bin/mysqld --defaults-file=/usr/local/mariadb/mariadb-10.06/my.cnf --datadir=/usr/local/mariadb/mariadb-10.06/data --port=3301


ExecStop=/usr/local/mariadb/mariadb-10.06/bin/mysqladmin --defaults-file=/usr/local/mariadb/mariadb-10.06/my.cnf shutdown


Restart=on-failure

LimitNOFILE=16384


[Install]

WantedBy=multi-user.target

---   ---   ---


Step-13 :   Reload system

$ sudo systemctl daemon-reload


Step-14 :   Check is service active

$ systemctl status mariadb@10.06


Step-15 :   Enable service, it helps you run automatically after Linux reboot

$ systemctl enable mariadb@10.06


Step-16 :   Start service

$ systemctl start mariadb@10.06

Now you can back to Step-14 check is service system active.


If you want to run "mariadb@10.06.service" manually :

$ systemctl disable mariadb@10.06


If you want to stop service system :

$ systemctl stop mariadb@10.06


Step-17 :   Grant user database

$ cd /usr/local/mariadb/mariadb-10.06/bin

$ sudo ./mariadb

$ use mysql;

$ GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'PswdPswd098$$$' WITH GRANT OPTION;

$ GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'PswdPswd098$$$' WITH GRANT OPTION;

$ GRANT ALL ON *.* TO 'mysql'@'localhost' IDENTIFIED BY 'PswdPswd098$$$' WITH GRANT OPTION;

$ GRANT ALL ON *.* TO 'mysql'@'%' IDENTIFIED BY 'PswdPswd098$$$' WITH GRANT OPTION;

$ GRANT ALL ON *.* TO 'mariadb.sys'@'localhost' IDENTIFIED BY 'PswdPswd098$$$' WITH GRANT OPTION;

$ FLUSH PRIVILEGES;

$ exit


Step-18 :   Test new password

$ ./mariadb -p

$ (enter new password)


If you are using tools like DBeaver, fill entire form needed, then click button "Test connection".


Repeat process above for :

mariadb-10.11.16-linux-systemd-x86_64.tar.gz

mariadb-11.4.10-linux-systemd-x86_64.tar.gz

mariadb-11.8.6-linux-systemd-x86_64.tar.gz


Done.


Note :

Don't forget use different port for each mariadb version.


If you find a special case like "mariadb 10.11 linux cannot remove user PUBLIC@"

$ mariadb -u root -p

$ SELECT User, Host FROM mysql.user WHERE User='PUBLIC';

$ UPDATE mysql.user SET Host = '%' WHERE User = 'PUBLIC';

$ DROP USER 'PUBLIC'@'%';

$ FLUSH PRIVILEGES;

$ exit


Note :

Don't forget remove unused users or unattended users from MariaDB.


On my Linux Ubuntu :

mariadb-10.6.25-linux-systemd-x86_64.tar.gz changed to "mariadb-10.06", with port 3001, and service system name "mariadb@10.06.service".

mariadb-10.11.16-linux-systemd-x86_64.tar.gz changed to "mariadb-10.11", with port 3002, and service system name "mariadb@10.11.service".

mariadb-11.4.10-linux-systemd-x86_64.tar.gz changed to "mariadb-11.04", with port 3003, and service system name "mariadb@11.04.service".

mariadb-11.8.6-linux-systemd-x86_64.tar.gz changed to "mariadb-11.08", with port 3004, and service system name "mariadb@11.08.service".


I actually not use Linux Ubuntu v24.04 as OS directly on my pc, but I use Docker. In another section I will show you a little magic by using Docker Desktop on Windows OS to run Linux OS a little bit properly like you use Linux OS for real, but it's about image and container on Docker.

See you next time.

Comments