Thursday, July 4, 2024
HomeDatabasesInstall MariaDB 11.0 on Rocky Linux 8 / AlmaLinux 8

Install MariaDB 11.0 on Rocky Linux 8 / AlmaLinux 8

MariaDB is popular relational database management system (RDBMS) created by original developers of MySQL as a fork but it is now maintained by MariaDB Foundation. There are many stable releases of MariaDB database server, and people will often choose what works for them and is compatible with the business application(s). Below are some of the reasons you’ll choose MariaDB as your ultimate database server solution:

  • For data storage: MariaDB can store large amounts of data in a structured manner and enables you to manage and organize your business data.
  • Data retrieval: With MariaDB you can quickly and easily retrieve data from your databases. This is essential for running applications and generating business reports.
  • Data analysis: Bundled with MariaDB is the advanced analytics capabilities, such as machine learning and data mining. These features are designed to help your business gain insights and make informed decisions based on available data.
  • Security: MariaDB is created lots of security features such as encryption, user authentication, and access control to ensure your data is safe and secure.
  • Scalability: MariaDB as a database server is highly scalable. It can handle large volumes of data and transactions for small business to ones that grow rapidly or handle fluctuating workloads.
  • Compatibility: MariaDB is fully compatible with MySQL. This means you can use MariaDB without any changes to the application code.

At the time of updating this article MariaDB 11.0 is the latest release but in RC. It is not recommended for use to handle production workloads. You can use it to test new features and expected changes in your applications for 100% compatibility.

Warning: Do not use alpha / RC releases in production!

If you need more information on MariaDB 11.0 release, check out official MariaDB releases page. For installation on Ubuntu based systems, see guide below.

MariaDB 11.0 Installation on Rocky Linux 8 / AlmaLinux 8

If you intent to install MariaDB 11.0 on Rocky Linux 8 / AlmaLinux 8 Linux system, the follow the steps captured in this section.

Step 1: Update your system

You can begin by ensuring that the system you’re working on is updated.

sudo dnf -y update

You can consider a reboot of the system is Kernel related updates were applied.

sudo reboot -f

Once the upgrade is done you can go to the next step.

Step 2: Add MariaDB APT repository

Once you’ve updated the system and installed packages, next we can configure MariaDB YUM repository which contains the latest packages of MariaDB database server.

curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version=11.0

Expected output from command execution.

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 11.0 is valid
# [info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
# [info] Adding trusted package signing keys...
/etc/pki/rpm-gpg ~
~
# [info] Successfully added trusted package signing keys
# [info] Cleaning package cache...
80 files removed

Listing available repositories on the system will confirm if the one we added is functional.

$ dnf -y repolist
repo id                                                                                        repo name
appstream                                                                                      Rocky Linux 8 - AppStream
baseos                                                                                         Rocky Linux 8 - BaseOS
extras                                                                                         Rocky Linux 8 - Extras
mariadb-main                                                                                   MariaDB Server
mariadb-maxscale                                                                               MariaDB MaxScale
mariadb-tools                                                                                  MariaDB Tools

Step 3: Install MariaDB Server & Client Packages

Reset AppStream MariaDB repository.

sudo dnf -qy module disable mariadb
sudo dnf module reset mariadb -y

To install MariaDB 11.0 server and client packages in your Rocky Linux 8 / AlmaLinux 8 system, run the following commands.

sudo dnf install MariaDB-server MariaDB-client MariaDB-backup

All required dependencies are installed. Just approve the installation by using y key.

Transaction Summary
======================================================================================================================================================================================================
Install  57 Packages

Total download size: 79 M
Installed size: 363 M
Is this ok [y/N]: y

Installed default version of MariaDB client can be checked using:

$ mariadb -V
mariadb from 11.0.1-MariaDB, client 15.2 for Linux (x86_64) using readline 5.1

Start and enable mariadb service.

$ sudo systemctl enable --now mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

Status should now show as running:

$ systemctl status mariadb
 mariadb.service - MariaDB 11.0.1 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Tue 2023-04-04 11:26:41 UTC; 2min 37s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 4590 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 4567 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSIT>
  Process: 4565 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 4577 (mariadbd)
   Status: "Taking your SQL requests now..."
    Tasks: 9 (limit: 23036)
   Memory: 204.1M
   CGroup: /system.slice/mariadb.service
           └─4577 /usr/sbin/mariadbd

Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] InnoDB: log sequence number 46141; transaction id 14
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] Plugin 'wsrep-provider' is disabled.
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] InnoDB: Buffer pool(s) load completed at 230404 11:26:41
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] Server socket created on IP: '0.0.0.0'.
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] Server socket created on IP: '::'.
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: 2023-04-04 11:26:41 0 [Note] /usr/sbin/mariadbd: ready for connections.
Apr 04 11:26:41 rocky8.mylab.io mariadbd[4577]: Version: '11.0.1-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Apr 04 11:26:41 rocky8.mylab.io systemd[1]: Started MariaDB 11.0.1 database server.

Check server version.

$ sudo mariadb -u root -e 'SELECT VERSION();'
+----------------+
| VERSION()      |
+----------------+
| 11.0.1-MariaDB |
+----------------+

Step 4: Secure MariaDB server installation

Secure your database server using mariadb-secure-installation script which performs various security-related tasks. You need to run the command as the root user or with sudo privileges.

sudo mariadb-secure-installation

For fresh installation there is no root password set, just press enter here.

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

Ensure that nobody can log into the MariaDB root user without the proper authorisation by setting the root password or using the unix_socket ensures that

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

Set root password and confirm to apply the change.

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

An anonymous user is available by default after installation, this allows anyone to log into MariaDB without having to have a user account created for them. We should remove this user for better security.

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

Disable remote connection to the database as root user. We only allow root to connect from ‘localhost‘.

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

Remote database named ‘test‘ that anyone can access.

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

Finally reload the privilege tables for all changes made to take effect immediately.

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

If you’ve completed all of the above steps, your MariaDB installation should now be secure.

Step 5: Test MariaDB 11.0 installation

You can connect to database server using mariadb command line tool. The -p flag prompts for password if running as non-root user.

mariadb -u root -p

If connection succeeds you’ll get shell prompt similar to below.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 11.0.1-MariaDB MariaDB Server

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)]>

To create a database in MariaDB, you can use the following SQL command:

CREATE DATABASE database_name;

See example below.

CREATE DATABASE testdb;

Next we create a user and grant privileges using the following SQL commands:

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'@'localhost';

To add sample data to your new database, you can use the INSERT command. Here’s an example:

USE testdb;

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50),
    email VARCHAR(50)
);

INSERT INTO users (name, email) VALUES
    ('John Doe', '[email protected]'),
    ('Jane Smith', '[email protected]'),
    ('Bob Johnson', '[email protected]');

This creates a new table called users in the local testdb database we created earlier, with three sample records inserted into the table. The table structure can be modified with the sample data as needed to suit your specific needs. To clean drop database and user.

drop database testdb;
drop user testuser@localhost;
exit;

Conclusion

Overall, as a business entity you need MariaDB database because it provides a powerful and flexible platform for managing and analyzing your data. The data analytics feature is essential in making informed decisions and staying competitive in today’s business environment. MariaDB database server can be used in a wide range of applications and industries – Education, Medical, Government, and in any business or corporate sector.

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments