sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install MariaDB 10.6 on Ubuntu Server 22.04
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install MariaDB 10.6 on Ubuntu Server 22.04

Samuel Siahaan
By Samuel Siahaan
Last updated: June 10, 2023
SHARE

Introduction MariaDB 10.6

MariaDB, an open-source relational database management system, is a powerful alternative to MySQL. Its latest version, MariaDB 10.6, brings enhanced features and performance improvements. If you’re using an Ubuntu Server 22.04, this step-by-step guide will walk you through the process of install MariaDB 10.6, ensure optimal performance and data management for your applications.

Contents
Introduction MariaDB 10.6Table of ContentsPrerequisites for Install MariaDB 10.6Install MariaDB 10.6 on Ubuntu Server 22.04Step 1: Update System PackagesStep 2: Install Required Packages for MariaDBStep 3: Add MariaDB RepositoryStep 4: Install MariaDB on Ubuntu 22.04Step 5: Start and Enable MariaDBStep 6: Install Secure MariaDBStep 7: Check MariaDB VersionStep 8: Basic MariaDB CommandsMariaDB Create DatabaseMariaDB add User and Grant PrivilegesCreate a Table and Add Data MariaDBStep 9: Optional: Configure MariaDBMariaDB Clean upConclusion

Table of Contents

  • Introduction MariaDB 10.6
  • Prerequisites for Install MariaDB 10.6
  • Install MariaDB 10.6 on Ubuntu Server 22.04
    • Step 1: Update System Packages
    • Step 2: Install Required Packages for MariaDB
    • Step 3: Add MariaDB Repository
    • Step 4: Install MariaDB on Ubuntu 22.04
    • Step 5: Start and Enable MariaDB
    • Step 6: Install Secure MariaDB
    • Step 7: Check MariaDB Version
    • Step 8: Basic MariaDB Commands
    • Step 9: Optional: Configure MariaDB
  • MariaDB Clean up
  • Conclusion

Prerequisites for Install MariaDB 10.6

Before we dive into the installation process, there is prerequisite you need to ensure are in place:

  • Ubuntu Server: Make sure you have a clean installation of Ubuntu Server. To set this up, follow our guide Initial Setup Ubuntu Server 22.04. You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.

Install MariaDB 10.6 on Ubuntu Server 22.04

Follow these steps to install MariaDB 10.6 on your Ubuntu Server 22.04 and enjoy its benefits:

Step 1: Update System Packages

Start by updating your system’s package list to ensure you’re working with the latest software versions:

- Advertisement -
samm@mariadb:~$ sudo apt-get update
samm@mariadb:~$ sudo apt-get upgrade

Updating the packages provides a stable foundation for the installation process.

Step 2: Install Required Packages for MariaDB

samm@mariadb:~$ sudo apt-get install wget curl
samm@mariadb:~$ sudo apt-get install software-properties-common dirmngr ca-certificates apt-transport-https -y

Step 3: Add MariaDB Repository

samm@mariadb:~$ sudo curl -o /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc 'https://mariadb.org/mariadb_release_signing_key.asc'

samm@mariadb:~$ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup

samm@mariadb:~$ sudo bash mariadb_repo_setup --os-type=ubuntu  --os-version=focal --mariadb-server-version=10.6

If successful the output should be similar to below.

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.6 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

MariaDB APT repository file is located inside the /etc/apt/sources.list.d directory:

samm@mariadb:~$ cat /etc/apt/sources.list.d/mariadb.list
# MariaDB Server
# To use a different major version of the server, or to pin to a specific minor version, change URI below.
deb [arch=amd64,arm64] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/ubuntu focal main

deb [arch=amd64,arm64] https://dlm.mariadb.com/repo/mariadb-server/10.6/repo/ubuntu focal main/debug

# MariaDB MaxScale
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
deb [arch=amd64] https://dlm.mariadb.com/repo/maxscale/latest/apt focal main

# MariaDB Tools
deb [arch=amd64] http://downloads.mariadb.com/Tools/ubuntu focal main

Step 4: Install MariaDB on Ubuntu 22.04

Next, update packages and install MariaDB server

samm@mariadb:~$ sudo apt-get update
samm@mariadb:~$ sudo apt-get install mariadb-server mariadb-client

“During my attempt to install the mariadb-client package, I came across an error notification.”:

- Advertisement -
mariadb-client-core-10.6 : Depends: libreadline5 (>= 5.2) but it is not installable

The work around was manually download and install libreadline5 package for Debian Buster

samm@mariadb:~$ wget http://ftp.us.debian.org/debian/pool/main/r/readline5/libreadline5_5.2+dfsg-3+b13_amd64.deb
samm@mariadb:~$ wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Next install the packages with following command:

samm@mariadb:~$ sudo apt-get -y install libdbd-mysql-perl libssl-dev
samm@mariadb:~$ sudo dpkg -i libreadline5_5.2+dfsg-3+b13_amd64.deb
samm@mariadb:~$ sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

The remaining step is install of MariaDB 10.6 Server and Client packages on Ubuntu 22.04:

- Advertisement -
samm@mariadb:~$ sudo apt-get update
samm@mariadb:~$ sudo apt-get install mariadb-server mariadb-client

Agree to continue with the installation of MariaDB 10.6 on Ubuntu 22.04:

Proceed to install MariaDB packages and all its dependencies:

....
The following NEW packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl
  libfcgi0ldbl libgdbm-compat4 libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
  liblwp-mediatypes-perl libmariadb3 libmpfr6 libndctl6 libperl5.32 libpmem1 libsigsegv2 libterm-readkey-perl libtimedate-perl liburi-perl lsof mariadb-client
  mariadb-client-10.6 mariadb-client-core-10.6 mariadb-common mariadb-server mariadb-server-10.6 mariadb-server-core-10.6 mysql-common perl perl-modules-5.32
  rsync
0 upgraded, 41 newly installed, 0 to remove and 0 not upgraded.
Need to get 37.5 MB of archives.
After this operation, 265 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Step 5: Start and Enable MariaDB

After install MariaDB, now run the following commands to start MariaDB and enable it to automatically start on system reboot

samm@mariadb:~$ sudo systemctl start mariadb
samm@mariadb:~$ 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

Ensure that MariaDB is up and running. You can check its status using:

samm@mariadb:~$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.6.12 Database Staging
     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 2022-12-14 23:54:00 WIB; 5s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 7856 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 7857 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 7859 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-enviro>
    Process: 7897 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 7899 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 7885 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 4676)
     Memory: 83.0M
        CPU: 257ms
     CGroup: /system.slice/mariadb.service
             └─7885 /usr/sbin/mariadbd

Dec 14 23:54:00 mariadb mariadbd[7885]: 2022-12-14 23:54:00 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Dec 14 23:54:00 mariadb mariadbd[7885]: 2022-12-14 23:54:00 0 [Note] Server socket created on IP: '0.0.0.0'.
Dec 14 23:54:00 mariadb mariadbd[7885]: 2022-12-14 23:54:00 0 [Note] Server socket created on IP: '::'.
Dec 14 23:54:00 mariadb mariadbd[7885]: 2022-12-14 23:54:00 0 [Note] InnoDB: Buffer pool(s) load completed at 221214 23:54:00
Dec 14 23:54:00 mariadb mariadbd[7885]: 2022-12-14 23:54:00 0 [Note] /usr/sbin/mariadbd: ready for connections.
Dec 14 23:54:00 mariadb mariadbd[7885]: Version: '10.6.12-MariaDB-1:10.6.12+maria~deb11'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distributi>
Dec 14 23:54:00 mariadb systemd[1]: Started MariaDB 10.6.12 Database Staging.
Dec 14 23:54:00 mariadb /etc/mysql/debian-start[7901]: Upgrading MySQL tables if necessary.
Dec 14 23:54:00 mariadb /etc/mysql/debian-start[7912]: Checking for insecure root accounts.
Dec 14 23:54:00 mariadb /etc/mysql/debian-start[7916]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables

Step 6: Install Secure MariaDB

Once MariaDB is successfully installed, proceed to secure it as below:

samm@mariadb:~$ sudo mariadb-secure-installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y
New password: [Your Password]
Re-enter new password: [Your Password]
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Step 7: Check MariaDB Version

To check MariaDB version, we need to login to MariaDB as below. Use -p if you have set the root password.

samm@mariadb:~$ mysql -u root -p
Enter password: [Your password]
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 129
Server version: 10.6.11-MariaDB-1:10.6.11+maria~deb11 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)]> SELECT VERSION();
+---------------------------------------+
| VERSION()                             |
+---------------------------------------+
| 10.6.12-MariaDB-1:10.6.11+maria~deb11 |
+---------------------------------------+
1 row in set (0.000 sec)

Step 8: Basic MariaDB Commands

Before you start using MariaDB, here some basic commands:

To access the MariaDB shell, use:

samm@mariadb:~$ mysql -u root -p

MariaDB Create Database

To create a database in MariaDB, login as shown above and run the below command.

#Create a new database
MariaDB [(none)]> CREATE DATABASE sammlinux_db;

#If the database with the same exists
MariaDB [(none)]> CREATE DATABASE sammlinux_db;
ERROR 1007 (HY000): Can't create database 'sammlinux_db'; database exists

#Create a database if already exits
MariaDB [(none)]> CREATE OR REPLACE DATABASE sammlinux_db;
Query OK, 2 rows affected (0.009 sec)

#First check if a database exists 
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS sammlinux_db;
Query OK, 1 row affected, 1 warning (0.000 sec)

# Check Databases MariaDB
MariaDB [(none)]> SHOW DATABASES;

MariaDB add User and Grant Privileges

To create a user and grant privileges;

#Create user mariadb
CREATE USER 'sammlinux-user'@'localhost' IDENTIFIED BY 'your-password';

#Grant all privileges to the user
GRANT ALL PRIVILEGES ON *.* TO 'sammlinux-user'@'localhost' IDENTIFIED BY 'your-password';

#Grant privileges to a specific database
GRANT ALL PRIVILEGES ON 'sammlinux_db'.* TO 'sammlinux-user'@'localhost';

#Remember to refresh the privileges
FLUSH privileges;

#To check user grants in MariaDB
SHOW GRANTS FOR 'sammlinux-user'@'locahost';

Create a Table and Add Data MariaDB

Once you have created a database, you can create table and add data into it

CREATE TABLE articles (articles_id INT, name VARCHAR(20), channel VARCHAR(20));
INSERT INTO articles (id,name,email) VALUES(56701,"samm","Linux")

Step 9: Optional: Configure MariaDB

Depending on your requirements, you can configure MariaDB for optimal performance. Open the configuration file:

samm@mariadb:~$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

Here, you can adjust settings like innodb_buffer_pool_size to allocate memory for caching data, or max_connections to control the number of concurrent connections.

MariaDB Clean up

To completely remove MariaDB, run the following commands.

samm@mariadb:~$ sudo apt purge mariadb-server
samm@mariadb:~$ sudo rm -rf /var/lib/mysql/

Conclusion

Installing MariaDB 10.6 on your Ubuntu Server 22.04 is a strategic move that brings performance enhancements, security features, and extended functionalities to your applications. By following this step-by-step guide, you’ve ensured a seamless installation process. With MariaDB 10.6’s powerful capabilities, your database management becomes more efficient and robust, positively impacting your applications’ performance and user experience. Embrace the benefits of MariaDB 10.6 and elevate your database management to new heights.

Also Read Our Other Guides :

  • How To Install MongoDB 6.0 on Debian 10 & 11
  • How To Install MongoDB 6.0 on Rocky Linux 9
  • How To Install MariaDB 10.6 on Debian 11 Server
  • How To Install MySQL 8.0 on Ubuntu Server 22.04
  • How To Install MongoDB 6.0 on Rocky Linux 9
  • How To Install DBeaver Community on Ubuntu 22.04

Finally, now you have learned how to install MariaDB 10.6 on Ubuntu Server 22.04.

TAGGED:DatabasesMariaDBMySqlRDBMSSQLUbuntu

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Install Apache Solr 9.1 on Debian 11
Next Article How To Install PHP 8.2 on Ubuntu Server 22.04
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

Ubuntu

How To Install Redis on Ubuntu Server 22.04

14 Min Read
Debian

How To Install MySQL 8.0 on Debian 11

14 Min Read
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

8 Min Read
Ubuntu

How To Install MongoDB 6.0 on Ubuntu Server 22.04

10 Min Read
Ubuntu

How To Install PHP 8.2 on Ubuntu Server 22.04

11 Min Read
Ubuntu

How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

9 Min Read
Ubuntu

How To Install Java Using OpenJDK 17 on Ubuntu 22.04

10 Min Read
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

14 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?