Wednesday, October 9, 2024
Google search engine
HomeData Modelling & AIHow To Install MariaDB 10.6 on Amazon Linux 2

How To Install MariaDB 10.6 on Amazon Linux 2

MariaDB is an OpenSource relational database management system known for its robustness and scalability with powerful storage engines. MariaDB was initially forked from MySQL and it is now the default database in most Linux distribution. MariaDB database has a variety of tools and plugins, making it widely applicable.

In this guide, we go though a step by step installation of MariaDB 10.6 on Amazon Linux 2.MariaDB 10.6 is the latest stable version of MariaDB at the time of updating this article. This new release comes with a number of new features as discussed below:

New features of MariaDB 10.6?

  • Ignored Indexes – These are indexes that are visible and maintained but not used by the optimizer
  • sys schema supported- This is a “system” database containing views and procedures for investigating performance problems.
  • SKIP LOCKED – Locked tables are skipped from being updated or selected.
  • JSON_TABLE() – can create a JSON table that can be used as a subquery from a JSON document.
  • Oracle compatibility – There are ongoing works in making MariaDB compatible with OracleDB with some Oracle Syntaxes and functions already added.
  • OFFSET…FETCH…[WITH TIES] – WITH TIES is an optional clause that adds extra functionality. Example as used

Improvements in MariaDB 10.6 from MariaDB 10.5 include:

  • Atomic DDL – CREATE, ALTER, DROP and RENAME are atomic and crash safe. If MariaDB server crashes while processing any of these operations, the change will either e done completely or not done at all.
  • InnoDB improvements – First insert to an empty table is faster. Also writes to temporary tables are avoided.Faster implicit and explicit temporary tables.
  • Clean up to remove unsupported features such as TukoDB Engine, Cassandra Engine, some InnoDB variables and some innodb_checksum_algorithm.
  • Improvements in Galera. Ability to enable encrypted connections between two nodes without downtime. Also added flags to specify if galera controversial compatible features should be enabled.

Step 1: Update System Packages

We always kickoff our installations with system updates and package upgrades.

sudo yum -y upgrade

Consider system reboot after a successful upgrade of the system

sudo reboot

Step 2: Add MariaDB 10.6 Repository to Amazon Linux 2

Login to your Amazon Linux 2 server and addMariaDB 10.6 Repository to Amazon Linux 2.

curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --os-type=rhel --os-version=7 --mariadb-server-version=10.6

If successful you should get an output with contents similar to this;

[info] Checking for script prerequisites.
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
[info] Adding trusted package signing keys...
/etc/pki/rpm-gpg /home/rocky
/home/rocky
[info] Successfully added trusted package signing keys
[info] Cleaning package cache...
62 files removed

Step 3: Install MariaDB 10.6 on Amazon Linux 2

Once you have saved the repo file, proceed to install MariaDB 10.6 on our Amazon Linux 2 system.

sudo yum install MariaDB-server MariaDB-client

Check all dependencies required and proceed if ok with you

....
Transaction Summary
======================================================================================================================================================================================================
Install  3 Packages (+12 Dependent packages)

Total download size: 53 M
Is this ok [y/d/N]: y

Step 4: Start and Secure MariaDB database server

Start MariaDb database service and set it for automatic startup when system reboots.

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

Secure database server installation using script provided by MariaDB team.

$ 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:
Re-enter new 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!

Test access to MariaDB shell console.

$ mysql -u root -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.5-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)]>

Run the below command to check MariaDB version

MariaDB [(none)]> SELECT VERSION();
+-------------------------------------+
| VERSION()                           |
+-------------------------------------+
| 10.6.5-MariaDB |
+-------------------------------------+
1 row in set (0.000 sec)

MariaDB [(none)]>

Step 5: Test MariaDB 10.6 on Amazon Linux 2

Create a test database

MariaDB [(none)]> CREATE DATABASE test_db1;
Query OK, 1 row affected (0.000 sec)

# Check Databases MariaDB
MariaDB [(none)]>  SHOW DATABASES;
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test_db1           |
+--------------------+
5 rows in set (0.000 sec)

MariaDB [(none)]>

Uninstall MariaDB 10.6 on Amazon Linux 2

To completely remove MariaDB database server and client packages together withs its dat, run the following commands:

sudo yum remove MariaDB-server MariaDB-client
sudo rm -rf /var/lib/mysql/
sudo rm /etc/my.cnf

You have successfully installed MariaDB 10.6 onAmazon Linux 2. We hope the guide has been insightful to you.

RELATED ARTICLES

Most Popular

Recent Comments