Most web, mobile and desktop application services you interact with on daily basis depend on database server to complete any transaction. The main purpose of a database server is to provide features of database management system (DBMS). In tech terms, a DBMS provides utilities for database administration and interacts with end users, applications, and databases. In this article we shall consider MariaDB database management system installation on Debian Linux.
MariaDB server is a free to use and open source, robust and fast database server based on the MySQL technology. MariaDB being relational database converts data into structured information and provides SQL interface for accessing stored data. Multiple storage engines and plug-ins are included in MariaDB, as well as support for geographic information system (GIS) and JavaScript Object Notation (JSON) features.
Some of the notable features in MariaDB 11.7 are:
- Vectors: Vectors are a feature that allow MariaDB Server to perform as a relational vector database. Previously available in the special Vector preview release, it has now been added to MariaDB Community Server 11.7.1 with various enhancements.
- InnoDB: Defaults change – the innodb_snapshot_isolation system variable now defaults to ON, previously was OFF
- Optimizer: Fix crash caused by query containing constant having clause.
- JSON: JSON_TABLE now properly unquotes strings and default values now allows non-string literals.
- mariadbd no longer hangs on startup when
--init-file
target does not exist. - LOAD DATA INFILE with geometry data no longer fails.
- Fix
heap-use-after-free
ingroup_concat
with compressed or GIS columns. - Trigger now works correctly with bulk update.
- Fix assertion failure in
find_producing_item
upon a query from a view. - Add new setting, –quick-max-column-width to the mariadb client for use in –quick mode.
The parts captured in this guide will describe how to install and configure MariaDB 11.7 on Debian 12 / Debian 11 systems. We won’t cover how to back up MariaDB data, or migration from an earlier MariaDB version. The highlighted steps in this article are only for new server installations.
Install MariaDB 11.7 on Debian 11 / Debian 10
In Debian Linux system, the MariaDB server is available in the following versions, each provided by upstream repository:
### Debian 12 ###
$ apt policy mariadb-server
mariadb-server:
Installed: (none)
Candidate: 1:10.11.6-0+deb12u1
Version table:
1:10.11.6-0+deb12u1 500
500 http://deb.debian.org/debian bookworm/main amd64 Packages
### Debian 11 ###
$ apt policy mariadb-server
mariadb-server:
Installed: (none)
Candidate: 1:10.5.15-0+deb11u1
Version table:
1:10.5.15-0+deb11u1 500
500 http://deb.debian.org/debian bullseye/main amd64 Packages
As can be see from the output, the versions of MariaDB server packages are a bit older. The most recent stable release is MariaDB 10.8. This version of MariaDB server and client can only be obtained from official project APT repository or by building it from source. We’ll go with the latter since it’s simple.
1 – Add MariaDB APT repository
Update your Debian system before you can proceed.
sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f
Depending on the nature of updates your system may be rebooted. Once online proceed to configure the repository
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=11.7
The process of adding repositories should take few seconds.
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 11.7 is valid
# [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
Confirm that the repository added is working.
$ sudo apt update
Hit:1 http://security.debian.org/debian-security bookworm-security InRelease
Hit:2 http://deb.debian.org/debian bookworm InRelease
Hit:3 http://apt.postgresql.org/pub/repos/apt bookworm-pgdg InRelease
Hit:4 http://deb.debian.org/debian bookworm-updates InRelease
Hit:5 https://downloads.mariadb.com/Tools/debian bookworm InRelease
Hit:6 https://dlm.mariadb.com/repo/mariadb-server/11.7/repo/debian bookworm InRelease
Hit:7 https://dlm.mariadb.com/repo/maxscale/latest/apt bookworm InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
2 – Install MariaDB 10.8 on Debian 11 / Debian 10
Install MariaDB server packages from the mariadb repository we just added into our system.
sudo apt install mariadb-server mariadb-client
Proceed with the installation by hitting the y key in your keyboard:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmariadb3 libsigsegv2
libterm-readkey-perl mariadb-client-compat mariadb-client-core mariadb-common mariadb-server-compat mariadb-server-core mysql-common pv rsync socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test netcat-openbsd doc-base python3-braceexpand
The following NEW packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmariadb3 libsigsegv2
libterm-readkey-perl mariadb-client mariadb-client-compat mariadb-client-core mariadb-common mariadb-server mariadb-server-compat mariadb-server-core mysql-common pv rsync socat
0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.5 MB of archives.
After this operation, 242 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
You can get more information on installed packages using the commands:
$ apt info mariadb-server
Package: mariadb-server
Version: 1:11.7.1+maria~deb12
Priority: optional
Section: database
Source: mariadb
Maintainer: MariaDB Developers <[email protected]>
Installed-Size: 55.8 MB
Provides: default-mysql-server, virtual-mysql-server
Pre-Depends: adduser (>= 3.40), debconf, mariadb-common (>= 1:11.7.1+maria~deb12)
Depends: galera-4 (>= 26.4), gawk, iproute2, libdbi-perl, lsof, mariadb-client (>= 1:11.7.1+maria~deb12), mariadb-server-core (>= 1:11.7.1+maria~deb12), passwd, perl (>= 5.6), procps, psmisc, rsync, socat, debconf (>= 0.5) | debconf-2.0, perl:any, libc6 (>= 2.34), libgcc-s1 (>= 3.0), libpam0g (>= 0.99.7.1), libssl3 (>= 3.0.0), libstdc++6 (>= 11), zlib1g (>= 1:1.1.4)
Recommends: libhtml-template-perl, mariadb-server-compat, pv
Suggests: mailx, mariadb-test, netcat-openbsd
Conflicts: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2, mariadb-server-10.3, mariadb-server-10.4, mariadb-server-10.5, mariadb-server-10.6, mariadb-server-10.7, mariadb-server-10.8, mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, mariadb-server-5.5, mysql-client-5.5, mysql-client-5.6, mysql-client-5.7, mysql-client-8.0, mysql-client-core-8.0, mysql-server, mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mysql-server-5.6, mysql-server-5.7, mysql-server-8.0, mysql-server-core-5.5, mysql-server-core-5.6, mysql-server-core-5.7, mysql-server-core-8.0, virtual-mysql-server
Breaks: handlersocket-mysql-5.5, percona-server-server-5.6, percona-xtradb-cluster-server-5.6, percona-xtradb-cluster-server-5.7
Replaces: handlersocket-mysql-5.5, libmariadbclient-dev (<< 5.5.0), libmariadbclient16, mariadb-client (<< 1:11.7.1+maria~deb12), mariadb-client-10.5, mariadb-client-10.6, mariadb-client-10.7, mariadb-client-10.8, mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2, mariadb-server-10.3, mariadb-server-10.4, mariadb-server-10.5, mariadb-server-10.6, mariadb-server-10.7, mariadb-server-10.8, mariadb-server-5.1, mariadb-server-5.2, mariadb-server-5.3, mariadb-server-5.5, mysql-client-5.5, mysql-client-5.6, mysql-client-5.7, mysql-client-8.0, mysql-client-core-8.0, mysql-server, mysql-server-4.1, mysql-server-5.0, mysql-server-5.1, mysql-server-5.5, mysql-server-5.6, mysql-server-5.7, mysql-server-8.0, percona-server-server-5.6, percona-xtradb-cluster-server-5.6, percona-xtradb-cluster-server-5.7, virtual-mysql-server
Homepage: https://mariadb.org/
Download-Size: 3,795 kB
APT-Manual-Installed: yes
APT-Sources: https://dlm.mariadb.com/repo/mariadb-server/11.7/repo/debian bookworm/main amd64 Packages
Description: MariaDB database server binaries
MariaDB is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MariaDB are speed, robustness and
ease of use.
.
This package includes the server binaries.
$ apt policy mariadb-server
mariadb-server:
Installed: 1:11.7.1+maria~deb12
Candidate: 1:11.7.1+maria~deb12
Version table:
*** 1:11.7.1+maria~deb12 1000
1000 https://dlm.mariadb.com/repo/mariadb-server/11.7/repo/debian bookworm/main amd64 Packages
100 /var/lib/dpkg/status
1:11.6.1+maria~deb12 1000
1000 https://dlm.mariadb.com/repo/mariadb-server/11.7/repo/debian bookworm/main amd64 Packages
1:11.5.1+maria~deb12 1000
1000 https://dlm.mariadb.com/repo/mariadb-server/11.7/repo/debian bookworm/main amd64 Packages
1:10.11.6-0+deb12u1 500
500 http://deb.debian.org/debian bookworm/main amd64 Packages
3 – Start service and secure MariaDB server
Start the mariadb service by running the commands below in your terminal:
sudo systemctl start mariadb.service
Enable the mariadb service to start at boot:
sudo systemctl enable mariadb.service
It is also recommended to improve your MariaDB security after installation by running the following command:
sudo mariadb-secure-installation
The command we just executed launches a fully interactive script, which prompts for each step in the process. The script enables you to improve security in the following ways:
- Setting a password for root accounts
- Removing anonymous users
- Disallowing remote root logins (outside the local host)
See our inputs below:
Enter current password for root (enter for none): <ENTER>
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
The only way to access MySQL root shell is password authentication.
$ mariadb -u root
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
$ mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 11.7.1-MariaDB-deb12 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)]>
Show your database status
MariaDB [(none)]> \s
--------------
mariadb from 11.7.1-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using EditLine wrapper
Connection id: 43
Current database:
Current user: root@localhost
SSL: Cipher in use is TLS_AES_256_GCM_SHA384, cert is OK
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 11.7.1-MariaDB-deb12 mariadb.org binary distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb3
Conn. characterset: utf8mb3
UNIX socket: /run/mysqld/mysqld.sock
Uptime: 8 min 2 sec
Threads: 1 Questions: 81 Slow queries: 0 Opens: 33 Open tables: 26 Queries per second avg: 0.168
--------------
MariaDB [(none)]>
4 – Configuring MariaDB Database server
MariaDB server configuration file is /etc/mysql/mariadb.conf.d/50-server.cnf
. On the same file you can set the following configuration directives:
bind-address
– setting the address MariaDB server listens on. Possible values for this are:- IPv4 address
- IPv6 address
- a host name
skip-networking
– Used to control whether MariaDB server listens for TCP/IP connections. Possible values are:- 0 – to listen for all clients
- 1 – to listen for local clients only
port
-The port that your MariaDB server listens for TCP/IP connections.
For any configuration change made on the file, a restart of MariaDB server is required.
sudo systemctl restart mariadb.service
Conclusion
Many other parameters can be adjusted on MariaDB server configuration file. In this article we’ve shown you how the installation of MariaDB 11.7 can be performed on Debian 12 / Debian 11 Linux system. Other GUI and CLI helper tools can be installed for easy administration of MariaDB server. This decision is entirely up to you.
More guides available: