Introduction MariaDB 10.9
MariaDB is a popular open-source relational database management system and a drop-in replacement for MySQL presently. MariaDB 10.9, in fact brings enhanced features and performance improvements. Are you ready to dive into the world of database management on your Debian 11 server? Well for this reason, in this tutorial we’ll guide you through the straightforward process of how to install MariaDB 10.9 on Debian 11 Server. Whether you’re a Linux novice or a seasoned pro, we’ve got you covered.
Table of Contents
- Introduction MariaDB 10.9
- Prerequisites for Install MariaDB 10.9
- Installing MariaDB 10.9 on Debian 11
- Step 1: Update System Packages
- Step 2: Install Required Packages
- Step 3: Add MariaDB 10.9 APT Repository
- Step 4: Install MariaDB 10.9 on Debian 11
- Step 5: Install Secure MariaDB 10.9
- Step 6: Start and Enable MariaDB 10.9
- Step 7: Check MariaDB Version
- Step 8: Basic MariaDB Commands
- Step 9: Optional: Configure MariaDB 10.9
- Conclusion
Prerequisites for Install MariaDB 10.9
Before we dive into the installing MariaDB 10.9 on Debian 11 there is prerequisite you need to ensure are in place:
- Debian 11 Server: Make sure you have a clean installation of Debian 11 Server. Additionally, you can deploy this on a physical machine or a virtual environment like VMware or VirtualBox. For detailed instructions, to set this up, use following guide :
- A stable internet connection of course.
Installing MariaDB 10.9 on Debian 11
Here’s a simple guide on how to install and configure MariaDB 10.9 on Debian 11. By following these steps, you can tap into the advantages it offers:
Step 1: Update System Packages
Start by updating your system’s package list to ensure you’re working with the latest software versions by using following commands:
samm@mariadb:~$ sudo apt-get update
samm@mariadb:~$ sudo apt-get upgrade
Step 2: Install Required Packages
To install the required packages for MariaDB in Debian 11, run the following commands:
samm@mariadb:~$ sudo apt-get install curl software-properties-common gnupg2
samm@mariadb:~$ sudo apt update && sudo apt -y full-upgrade
Step 3: Add MariaDB 10.9 APT Repository
Now, let’s dive into the main event: installing MariaDB 10.9. To install MariaDB 10.9, firstly, you’ll need to add the official MariaDB repository. Furthermore, this repository provides access to the latest MariaDB packages. For this purpose we’ll use the APT package manager for this. In your terminal, execute the following command:
samm@mariadb:~$ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
samm@mariadb:~$ sudo bash mariadb_repo_setup --mariadb-server-version=10.9
If successful, the output should similar the following:
# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.9 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
Step 4: Install MariaDB 10.9 on Debian 11
Now, it’s time to install MariaDB. First, update packages and then proceed to install the MariaDB server.
samm@mariadb:~$ sudo apt-get update
samm@mariadb:~$ sudo apt-get install mariadb-server mariadb-client
Then this proceed to install MariaDB packages and all its dependencies:
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 libclone-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl
libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl libtimedate-perl
liburi-perl mariadb-client-core mariadb-common mariadb-server-core mysql-common psmisc pv socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test netcat-openbsd doc-base
The following NEW packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdaxctl1 libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl
libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmariadb3 libndctl6 libpmem1 libsigsegv2 libterm-readkey-perl libtimedate-perl
liburi-perl mariadb-client mariadb-client-core mariadb-common mariadb-server mariadb-server-core mysql-common psmisc pv socat
0 upgraded, 36 newly installed, 0 to remove and 1 not upgraded.
Need to get 29.1 MB of archives.
After this operation, 222 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Step 5: Install Secure MariaDB 10.9
For security reasons, in the first place run the provided script to secure your MariaDB installation. Therefore, follow the prompts to configure settings like setting a root password, removing anonymous users, disallowing remote root login, and removing the test database. In addition these steps help enhance the security of your MariaDB installation,
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 6: Start and Enable MariaDB 10.9
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
Confirm that MariaDB is running by using following command:
samm@mariadb:~$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.9.8 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 Fri 2023-09-08 23:30:54 WIB; 8min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 5438 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 9 (limit: 2321)
Memory: 211.5M
CPU: 293ms
CGroup: /system.slice/mariadb.service
└─5438 /usr/sbin/mariadbd
Sep 08 23:30:53 server-mariadb mariadbd[5438]: 2023-09-08 23:30:53 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Sep 08 23:30:53 server-mariadb mariadbd[5438]: 2023-09-08 23:30:53 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Sep 08 23:30:53 server-mariadb mariadbd[5438]: 2023-09-08 23:30:53 0 [Note] Server socket created on IP: '127.0.0.1'.
Sep 08 23:30:54 server-mariadb mariadbd[5438]: 2023-09-08 23:30:54 0 [Note] InnoDB: Buffer pool(s) load completed at 230908 23:30:54
Sep 08 23:30:54 server-mariadb mariadbd[5438]: 2023-09-08 23:30:54 0 [Note] /usr/sbin/mariadbd: ready for connections.
Sep 08 23:30:54 server-mariadb mariadbd[5438]: Version: '10.9.8-MariaDB-1:10.9.8+maria~deb11' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
Sep 08 23:30:54 server-mariadb systemd[1]: Started MariaDB 10.9.8 database server.
Sep 08 23:30:54 server-mariadb /etc/mysql/debian-start[5456]: Upgrading MySQL tables if necessary.
Sep 08 23:30:54 server-mariadb /etc/mysql/debian-start[5469]: Checking for insecure root accounts.
Sep 08 23:30:54 server-mariadb /etc/mysql/debian-start[5473]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
Step 7: Check MariaDB Version
In order 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 41
Server version: 10.9.8-MariaDB-1:10.9.8+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.9.8-MariaDB-1:10.9.8+maria~deb11 |
+-------------------------------------+
1 row in set (0.000 sec)
Step 8: Basic MariaDB Commands
Before you start using MariaDB 10.9, here some basic commands:
To access the MariaDB shell, use following command:
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 use following syntax;
#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 10.9
Depending on your requirements, for that reason you can configure MariaDB 10.9 for optimal performance. For instance, you can fine-tune settings to enhance its efficiency further. Open the configuration file with following command:
samm@mariadb:~$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
Here you can adjust settings like innodb_buffer_pool_size
in order to allocate memory for caching data, or max_connections
to control the number of concurrent connections.
MariaDB 10.9 Clean up
To completely remove MariaDB 10.9, run the following commands.
samm@mariadb:~$ sudo apt purge mariadb-server
samm@mariadb:~$ sudo rm -rf /var/lib/mysql/
Conclusion
To begin with, in this tutorial, we’ve walked you through the process of installing MariaDB 10.9 on your Debian 11 server. Subsequently, we began by ensuring your system was up to date, followed by the installation of MariaDB. We also secured the installation and verified that everything is running smoothly.
At this point, you’re ready to dive deeper into the world of database management on your Debian 11 server. Additionally, you can explore advanced configurations and optimize performance to meet your specific needs. Whether you’re using it for personal projects or business endeavors, MariaDB is a powerful tool that will help you manage your data efficiently.
With this step-by-step guide, even if new to Linux and database management can get up and running quickly. So, what are you waiting for? For that reason start exploring the possibilities that MariaDB on Debian 11 can offer!
Firstly, if you encounter any issues or have specific database-related tasks, refer to the MariaDB documentation for more information and guidance. Additionally, feel free to explore the numerous features and capabilities that MariaDB offers for building and maintaining robust database applications. Lastly, happy database management!
Also Read Our Other Guides :
- How To Install MariaDB 10.6 on Debian 11 Server
- How To Install MariaDB 10.6 on Ubuntu Server 22.04
- How To Install MySQL 8.0 on Debian 11
- How To Install DBeaver Community on Ubuntu 22.04
As I have shown, now you have learned how to install MariaDB 10.9 on Debian 11 Server.