How to Install MariaDB 11 on Debian 12 Linux

In our last article, ‘The Story Behind the Acquisition of MySQL‘ we discussed the need to fork MySQL, the rise of MariaDB, its features, a comparative study of MariaDB and MySQL, the migration of some of the world’s renowned corporations, and companies (such as Google and Wikipedia) from MySQL to MariaDB, and many other technical and non-technical aspects of it.

This tutorial will guide you through the process of installing MariaDB on a Debian 12 server and ensuring that it is running with a secure initial configuration.

Step 1: Update Debian System

To ensure you have the latest package information, update the system’s package list by running the following apt commands.

sudo apt update
sudo apt upgrade
Upgrade Debian System
Upgrade Debian System

Step 2: Add MariaDB Repository

Debian 12 includes a default MariaDB version in its repositories, but for MariaDB 11, you need to add the official MariaDB repository that contains software packages related to MariaDB Server, including the server itself, clients, and utilities.

Create the file /etc/apt/sources.list.d/mariadb.sources and add the repository information as shown.

sudo nano /etc/apt/sources.list.d/mariadb.sources

Add the following lines to the file.

# MariaDB 11.1 repository list - created 2023-11-20 07:47 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/11.1/debian
URIs: https://mirrors.aliyun.com/mariadb/repo/11.1/debian
Suites: bookworm
Components: main
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
Add MariaDB Repository
Add MariaDB Repository

Next, to confirm the authenticity of the packages, import the MariaDB GPG key with the following commands.

sudo apt install apt-transport-https curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'

Step 3: Install MariaDB 11 on Debian

After enabling the MariaDB repository, you can install MariaDB 11 using the following commands.

sudo apt update
sudo apt install mariadb-server
Install MariaDB on Debian
Install MariaDB on Debian

Step 4: Secure MariaDB Installation

Once MariaDB installation is completed, you need to secure its installation by running the security script as shown.

sudo mysql_secure_installation

You’ll be asked to set a password for the root user, remove the anonymous user, disable remote root login, remove the test database, and reload the privileges.

Secure MariaDB on Debian
Secure MariaDB on Debian

Step 5: Verify MariaDB Installation

To check the version of MariaDB, you need to run the following mysql command, which will display information about the MariaDB version currently installed on your Debian system.

mysql --version

Sample Output:

mysql from 11.1.3-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using  EditLine wrapper

You should also verify that MariaDB is running properly by running the following systemctl command.

sudo systemctl status mariadb
Check MariaDB Running Status
Check MariaDB Running Status

Step 6: Connect to MariaDB Shell

Access the MariaDB command-line interface to confirm that you can connect successfully.

sudo mariadb -u root -p

Enter the root password when prompted. If you can log in without any issues, MariaDB is installed and configured correctly.

Connect to MariaDB
Connect to MariaDB

Step 7: Create a MySQL User

To create a user in MySQL, you can use the following SQL command with your desired username and password as shown.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Create MySQL User
Create MySQL User
Conclusion

You’ve successfully installed MariaDB 11 on your Debian 12 system. Remember to refer to the MariaDB documentation for additional configuration options and best practices.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

10 Comments

Leave a Reply
  1. I found the article to be very helpful and well-written. The step-by-step instructions provided a clear and concise guide for setting up MariaDB on Debian 12.

    Reply
  2. add-apt-repository ‘deb http://mariadb.biz.net.id//repo/10.1/debian jessie main’
    —— it works for me:
    Accept this solution? [Y/n/q/?] n
    The following actions will resolve these dependencies:

    Install the following packages:
    1) galera-3 [25.3.19-jessie ()]
    2) libmariadbclient18 [10.1.20+maria-1~jessie ()]
    3) libmysqlclient18 [10.1.20+maria-1~jessie ()]
    4) mariadb-client-core-10.1 [10.1.20+maria-1~jessie ()]
    5) mariadb-server-core-10.1 [10.1.20+maria-1~jessie ()]

    Keep the following packages at their current version:
    6) mariadb-client [Not Installed]
    7) mariadb-client-10.1 [Not Installed]
    8) mariadb-server [Not Installed]
    9) mariadb-server-10.1 [Not Installed]

    Reply
  3. Followed above process to install MariaDB in raspberry pi(OS Debian Jessie) after,

    # apt-get install mariadb-server mariadb-client
    

    I checked mysql -v and mysql --version but gives error mysql: command not found

    Reply
    • Krzy,

      Thanks for a tip, but to verify it have you tried in Jessie? If yes, could you share the screenshot where Sid makes dependencies errors while installing MariaDB?

      Reply
      • Unfortunately I can’t give you screenshots because it’s a past now. I was installing mariadb on Debian 8 for my client and apt-get refused to install mariadb because there were not compatible version of packets. Apt-get displayed only that those missing/bad version packets couldn’t be installed. Searching for this errors gave me links with resolving different, newer in Linux distribution than in mariadb repo, issues. This gave me a clue, that maybe changing “sid” to “jessie” in apt-get’s sources.list will be a resolution and I’ve had right. After that installation went without problems.

        Reply
        • @Kzyho,

          Thanks for detailed information, let me give a try on Debian 8 and see whether it still gives the same error and force me to change from sid to jessie, will update you my findings..

          Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.