Installing MariaDB Community Server 10.5 on Ubuntu 20.04 LTS

Installing MariaDB Community Server 10.5 on Ubuntu 20.04 LTS

In this article, we are installing MariaDB Community Edition on Ubuntu 20.04 LTS, and, a in future post we will configure replication.

I followed these steps from the MariaDB docs, here:

But first, since this is a new server, let's upgrade it.

Update the package lists for upgrades for packages that need upgrading.

ubuntu@ubu2004mariadb02:~$ sudo apt-get update
[sudo] password for ubuntu:
.
.
.
Reading package lists... Done
ubuntu@ubu2004mariadb02:~$


Upgrade the packages, listed before.

ubuntu@ubu2004mariadb02:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  base-files linux-generic linux-headers-generic linux-image-generic sosreport ubuntu-advantage-tools ubuntu-server
The following packages will be upgraded:
  libnss-systemd libpam-systemd libsystemd0 libudev1 systemd systemd-sysv systemd-timesyncd udev
8 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
Need to get 5,844 kB of archives.
After this operation, 15.4 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
.
.
.
Processing triggers for initramfs-tools (0.136ubuntu6.6) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-77-generic
ubuntu@ubu2004mariadb02:~$

Configure the APT package repository.

wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

ubuntu@ubu2004mariadb02:~$ wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
--2021-07-21 10:15:16--  https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
Resolving downloads.mariadb.com (downloads.mariadb.com)... 104.20.67.208, 104.20.68.208, 172.67.32.229, ...
Connecting to downloads.mariadb.com (downloads.mariadb.com)|104.20.67.208|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26401 (26K) [application/octet-stream]
Saving to: ‘mariadb_repo_setup’

mariadb_repo_setup                                  100%[=================================================================================================================>]  25.78K  36.9KB/s    in 0.7s

2021-07-21 10:15:17 (36.9 KB/s) - ‘mariadb_repo_setup’ saved [26401/26401]

We check that we actually downloaded the file.

ubuntu@ubu2004mariadb02:~$ ls -lrt
total 28
-rwxrwxr-x 1 ubuntu ubuntu 26401 Jul  6 12:48 mariadb_repo_setup
ubuntu@ubu2004mariadb02:~$ echo "32e01fbe65b4cecc074e19f04c719d1a600e314236c3bb40d91e555b7a2abbfc mariadb_repo_setup" \
>     | sha256sum -c -
mariadb_repo_setup: OK

We grant execution privileges.

ubuntu@ubu2004mariadb02:~$ chmod +x mariadb_repo_setup
ubuntu@ubu2004mariadb02:~$ sudo ./mariadb_repo_setup \
>    --mariadb-server-version="mariadb-10.5"
[info] Checking for script prerequisites.
[info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list
[info] Adding trusted package signing keys...
[info] Running apt-get update...
[info] Done adding trusted package signing keys
ubuntu@ubu2004mariadb02:~$
ubuntu@ubu2004mariadb02:~$ sudo apt update
Hit:1 http://gb.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://gb.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://gb.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 http://gb.archive.ubuntu.com/ubuntu focal-security InRelease
Hit:6 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal InRelease
Hit:4 https://downloads.mariadb.com/Tools/ubuntu focal InRelease
Get:7 https://dlm.mariadb.com/repo/maxscale/latest/apt focal InRelease [4,966 B]
Fetched 4,966 B in 1s (6,404 B/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
7 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@ubu2004mariadb02:~$

Install MariaDB Community Server and package dependencies:

ubuntu@ubu2004mariadb02:~$ sudo apt install mariadb-server mariadb-backup
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  galera-4 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
  libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common
  mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test
The following NEW packages will be installed:
  galera-4 libcgi-fast-perl libcgi-pm-perl libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
  libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libmysqlclient21 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-backup mariadb-client-10.5 mariadb-client-core-10.5
  mariadb-common mariadb-server mariadb-server-10.5 mariadb-server-core-10.5 mysql-common socat
0 upgraded, 28 newly installed, 0 to remove and 7 not upgraded.
Need to get 35.8 MB of archives.
After this operation, 256 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
.
.
.
Processing triggers for systemd (245.4-4ubuntu3.10) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
ubuntu@ubu2004mariadb02:~$

Start MariaDB and check the status.

ubuntu@ubu2004mariadb02:~$ sudo systemctl start mariadb
ubuntu@ubu2004mariadb02:~$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5.11 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             └─migrated-from-my.cnf-settings.conf
     Active: active (running) since Wed 2021-07-21 10:23:36 UTC; 38s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 14255 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 4617)
     Memory: 74.9M
     CGroup: /system.slice/mariadb.service
             └─14255 /usr/sbin/mariadbd

Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: information_schema
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: mysql
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: performance_schema
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: Phase 6/7: Checking and upgrading tables
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: Processing databases
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: information_schema
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: performance_schema
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[14274]: OK
Jul 21 10:23:40 ubu2004mariadb02 /etc/mysql/debian-start[15147]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
ubuntu@ubu2004mariadb02:~$

Once we know that it's running we can connect to it.

ubuntu@ubu2004mariadb02:~$ sudo mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.5.11-MariaDB-1:10.5.11+maria~focal mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> quit
Bye

and we can enable it so next time we reboot the server, the MariaDB service will start automatically.

ubuntu@ubu2004mariadb02:~$ sudo systemctl enable mariadb
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb
ubuntu@ubu2004mariadb02:~$

As mentioned, in a future post we will configure replication.