以下の内容はhttps://souiunogaii.hatenablog.com/entry/almalinux96-mariadb118-installより取得しました。


AlmaLinux9.6にMariaDB11.8をインストールする手順

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・AlmaLinux9.6にMariaDB11.8をインストールする方法を知りたい。
・具体的な手順を教えてほしい。

こういった疑問に答えます。

本記事の内容

  1. AlmaLinux9.6にMariaDB11.8をインストールする手順

サトナカ (@souiunogaii)

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

AlmaLinux9.6にMariaDB11.8をインストールする手順

参考ページ

mariadb.org

リポジトリの導入

上記のページでリポジトリに必要な設定を作ってコピーします。

Red Hat Enterprise Linux 9を選択

バージョン11.8を選択

山形大学ミラーサイトを選択

作成されたものをそのままコピー

/etc/yum.repos.d/MariaDB.repo
[root@a-maria01 ~]# vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 11.8 RedHatEnterpriseLinux repository list - created 2025-09-02 02:23 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.8/rhel/$releasever/$basearch
baseurl = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/11.8/rhel/$releasever/$basearch
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

MariaDB11.8のインストール

dnf install MariaDB-server MariaDB-client
[root@a-maria01 ~]# sudo dnf install MariaDB-server MariaDB-client
メタデータの期限切れの最終確認: 0:00:12 前の 20250902112451秒 に実施しました。
依存関係が解決しました。
====================================================================================================
 パッケージ                    Arch           バージョン                    リポジトリー      サイズ
====================================================================================================
インストール:
 MariaDB-client                x86_64         11.8.3-1.el9                  mariadb           9.6 M
 MariaDB-server                x86_64         11.8.3-1.el9                  mariadb            18 M
依存関係のインストール:
 MariaDB-common                x86_64         11.8.3-1.el9                  mariadb            92 k
 MariaDB-shared                x86_64         11.8.3-1.el9                  mariadb           130 k
     置き換え  mariadb-connector-c.x86_64 3.2.6-1.el9_0
     置き換え  mariadb-connector-c-config.noarch 3.2.6-1.el9_0
 boost-program-options         x86_64         1.75.0-10.el9                 appstream         104 k
 galera-4                      x86_64         26.4.23-1.el9                 mariadb           1.2 M
 perl-DBI                      x86_64         1.643-9.el9                   appstream         700 k
 perl-DynaLoader               x86_64         1.47-481.1.el9_6              appstream          24 k
 perl-Math-BigInt              noarch         1:1.9998.18-460.el9           appstream         188 k
 perl-Math-Complex             noarch         1.59-481.1.el9_6              appstream          45 k
 perl-Sys-Hostname             x86_64         1.23-481.1.el9_6              appstream          15 k
弱い依存関係のインストール:
 MariaDB-client-compat         noarch         11.8.3-1.el9                  mariadb            11 k
 MariaDB-server-compat         noarch         11.8.3-1.el9                  mariadb           9.0 k
 socat                         x86_64         1.7.4.1-6.el9_6.1             appstream         299 k

トランザクションの概要
====================================================================================================
インストール  14 パッケージ

合計サイズ: 31 M
ダウンロードサイズの合計: 29 M
これでよろしいですか? [y/N]:
パッケージのダウンロード:
[SKIPPED] boost-program-options-1.75.0-10.el9.x86_64.rpm: Already downloaded
[SKIPPED] perl-DBI-1.643-9.el9.x86_64.rpm: Already downloaded
[SKIPPED] perl-DynaLoader-1.47-481.1.el9_6.x86_64.rpm: Already downloaded
[SKIPPED] perl-Math-BigInt-1.9998.18-460.el9.noarch.rpm: Already downloaded
[SKIPPED] perl-Math-Complex-1.59-481.1.el9_6.noarch.rpm: Already downloaded
[SKIPPED] perl-Sys-Hostname-1.23-481.1.el9_6.x86_64.rpm: Already downloaded
[SKIPPED] socat-1.7.4.1-6.el9_6.1.x86_64.rpm: Already downloaded
(8/14): MariaDB-client-compat-11.8.3-1.el9.noarch.rpm               132 kB/s |  11 kB     00:00
(9/14): MariaDB-common-11.8.3-1.el9.x86_64.rpm                      834 kB/s |  92 kB     00:00
(10/14): MariaDB-server-compat-11.8.3-1.el9.noarch.rpm              198 kB/s | 9.0 kB     00:00
(11/14): MariaDB-shared-11.8.3-1.el9.x86_64.rpm                     1.3 MB/s | 130 kB     00:00
(12/14): galera-4-26.4.23-1.el9.x86_64.rpm                          2.9 MB/s | 1.2 MB     00:00
(13/14): MariaDB-client-11.8.3-1.el9.x86_64.rpm                     4.3 MB/s | 9.6 MB     00:02
(14/14): MariaDB-server-11.8.3-1.el9.x86_64.rpm                     6.0 MB/s |  18 MB     00:03
----------------------------------------------------------------------------------------------------
合計                                                                9.2 MB/s |  29 MB     00:03
MariaDB                                                             100 kB/s | 6.4 kB     00:00
GPG 鍵 0xC74CD1D8 をインポート中:
 Userid     : "MariaDB Signing Key <signing-key@mariadb.org>"
 Fingerprint: 177F 4010 FE56 CA33 3630 0305 F165 6F24 C74C D1D8
 From       : https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/yum/RPM-GPG-KEY-MariaDB
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                            1/1
  インストール中   : MariaDB-shared-11.8.3-1.el9.x86_64                                        1/16
  scriptletの実行中: MariaDB-shared-11.8.3-1.el9.x86_64                                        1/16
  インストール中   : MariaDB-common-11.8.3-1.el9.x86_64                                        2/16
  インストール中   : socat-1.7.4.1-6.el9_6.1.x86_64                                            3/16
  インストール中   : perl-Sys-Hostname-1.23-481.1.el9_6.x86_64                                 4/16
  インストール中   : perl-Math-Complex-1.59-481.1.el9_6.noarch                                 5/16
  インストール中   : perl-Math-BigInt-1:1.9998.18-460.el9.noarch                               6/16
  インストール中   : perl-DynaLoader-1.47-481.1.el9_6.x86_64                                   7/16
  インストール中   : perl-DBI-1.643-9.el9.x86_64                                               8/16
  インストール中   : MariaDB-client-compat-11.8.3-1.el9.noarch                                 9/16
  インストール中   : MariaDB-client-11.8.3-1.el9.x86_64                                       10/16
  インストール中   : boost-program-options-1.75.0-10.el9.x86_64                               11/16
  scriptletの実行中: galera-4-26.4.23-1.el9.x86_64                                            12/16
  インストール中   : galera-4-26.4.23-1.el9.x86_64                                            12/16
  scriptletの実行中: galera-4-26.4.23-1.el9.x86_64                                            12/16
  インストール中   : MariaDB-server-compat-11.8.3-1.el9.noarch                                13/16
  scriptletの実行中: MariaDB-server-11.8.3-1.el9.x86_64                                       14/16
usermod: 変更はありません

  インストール中   : MariaDB-server-11.8.3-1.el9.x86_64                                       14/16
  scriptletの実行中: MariaDB-server-11.8.3-1.el9.x86_64                                       14/16
2025-09-02 11:25:42 0 [Warning] mariadbd: io_uring_queue_init() failed with EPERM: sysctl kernel.io_uring_disabled has the value 2, or 1 and the user of the process is not a member of sysctl kernel.io_uring_group. (see man 2 io_uring_setup).
create_uring failed: falling back to libaio


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mariadb
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/


  廃止             : mariadb-connector-c-3.2.6-1.el9_0.x86_64                                 15/16
  廃止             : mariadb-connector-c-config-3.2.6-1.el9_0.noarch                          16/16
  scriptletの実行中: MariaDB-server-11.8.3-1.el9.x86_64                                       16/16
  scriptletの実行中: mariadb-connector-c-config-3.2.6-1.el9_0.noarch                          16/16
  検証中           : MariaDB-client-11.8.3-1.el9.x86_64                                        1/16
  検証中           : MariaDB-client-compat-11.8.3-1.el9.noarch                                 2/16
  検証中           : MariaDB-common-11.8.3-1.el9.x86_64                                        3/16
  検証中           : MariaDB-server-11.8.3-1.el9.x86_64                                        4/16
  検証中           : MariaDB-server-compat-11.8.3-1.el9.noarch                                 5/16
  検証中           : MariaDB-shared-11.8.3-1.el9.x86_64                                        6/16
  検証中           : mariadb-connector-c-3.2.6-1.el9_0.x86_64                                  7/16
  検証中           : mariadb-connector-c-config-3.2.6-1.el9_0.noarch                           8/16
  検証中           : galera-4-26.4.23-1.el9.x86_64                                             9/16
  検証中           : boost-program-options-1.75.0-10.el9.x86_64                               10/16
  検証中           : perl-DBI-1.643-9.el9.x86_64                                              11/16
  検証中           : perl-DynaLoader-1.47-481.1.el9_6.x86_64                                  12/16
  検証中           : perl-Math-BigInt-1:1.9998.18-460.el9.noarch                              13/16
  検証中           : perl-Math-Complex-1.59-481.1.el9_6.noarch                                14/16
  検証中           : perl-Sys-Hostname-1.23-481.1.el9_6.x86_64                                15/16
  検証中           : socat-1.7.4.1-6.el9_6.1.x86_64                                           16/16

インストール済み:
  MariaDB-client-11.8.3-1.el9.x86_64                MariaDB-client-compat-11.8.3-1.el9.noarch
  MariaDB-common-11.8.3-1.el9.x86_64                MariaDB-server-11.8.3-1.el9.x86_64
  MariaDB-server-compat-11.8.3-1.el9.noarch         MariaDB-shared-11.8.3-1.el9.x86_64
  boost-program-options-1.75.0-10.el9.x86_64        galera-4-26.4.23-1.el9.x86_64
  perl-DBI-1.643-9.el9.x86_64                       perl-DynaLoader-1.47-481.1.el9_6.x86_64
  perl-Math-BigInt-1:1.9998.18-460.el9.noarch       perl-Math-Complex-1.59-481.1.el9_6.noarch
  perl-Sys-Hostname-1.23-481.1.el9_6.x86_64         socat-1.7.4.1-6.el9_6.1.x86_64

完了しました!

確認

[root@a-maria01 ~]# dnf list installed | grep mariadb
MariaDB-client.x86_64                          11.8.3-1.el9                     @mariadb
MariaDB-client-compat.noarch                   11.8.3-1.el9                     @mariadb
MariaDB-common.x86_64                          11.8.3-1.el9                     @mariadb
MariaDB-server.x86_64                          11.8.3-1.el9                     @mariadb
MariaDB-server-compat.noarch                   11.8.3-1.el9                     @mariadb
MariaDB-shared.x86_64                          11.8.3-1.el9                     @mariadb
galera-4.x86_64                                26.4.23-1.el9                    @mariadb

設定ファイルの変更

/etc/my.cnf.d/server.cnf
     23 # This group is read by both MariaDB and MySQL servers
     24 [mysqld]
     25 character-set-server = utf8mb4  ←★★★変更
/etc/my.cnf.d/client.cnf
      1 #
      2 # These two groups are read by the client library
      3 # Use it for options that affect all clients, but not the server
      4 #
      5
      6
      7 [client]
      8 default-character-set=utf8mb4  ←★★★変更

サービス起動

systemctl start mariadb
[root@a-maria01 ~]# systemctl start mariadb
[root@a-maria01 ~]# systemctl status mariadb
● mariadb.service - MariaDB 11.8.3 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; preset: disabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
             mqmigrated-from-my.cnf-settings.conf
     Active: active (running) since Tue 2025-09-02 11:31:55 JST; 5s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 3869 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/>
    Process: 3891 ExecStartPost=/bin/rm -f /var/lib/mysql/wsrep-start-position (code=exited, status>
   Main PID: 3879 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 13694)
     Memory: 126.1M
        CPU: 735ms
     CGroup: /system.slice/mariadb.service
             mq3879 /usr/sbin/mariadbd

 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] Plugin 'FEEDBACK' is disabl>
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] Plugin 'wsrep-provider' is >
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] InnoDB: Loading buffer pool>
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] InnoDB: Buffer pool(s) load>
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] Server socket created on IP>
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] Server socket created on IP>
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] mariadbd: Event Scheduler: >
 902 11:31:55 a-maria01 mariadbd[3879]: 2025-09-02 11:31:55 0 [Note] /usr/sbin/mariadbd: ready f>
 902 11:31:55 a-maria01 mariadbd[3879]: Version: '11.8.3-MariaDB'  socket: '/var/lib/mysql/mysql>
 9月 02 11:31:55 a-maria01 systemd[1]: Started MariaDB 11.8.3 database server.

自動起動の設定

systemctl enable mariadb
[root@a-maria01 ~]# systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@a-maria01 ~]# systemctl is-enabled mariadb
enabled

セキュアインストレーションの実行(rootのパスワード登録)

mariadb-secure-installation
[root@a-maria01 ~]# 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):   ←★★★何も入れずにEnter
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]   ←★★★何も入れずにEnter
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]   ←★★★何も入れずにEnter
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]   ←★★★何も入れずにEnter
 ... 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]   ←★★★何も入れずにEnter
 ... 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]   ←★★★何も入れずにEnter
 - 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]   ←★★★何も入れずにEnter
 ... 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!

サービス再起動

[root@a-maria01 ~]# systemctl restart mariadb

初回ログイン

mysql -u root -p ★★★自分で決めたパスワード
[root@a-maria01 ~]# mysql -u root -p
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 11.8.3-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)]>

テスト

テストDBを作成

MariaDB [(none)]> create database test_db;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test_db            |
+--------------------+
5 rows in set (0.001 sec)
MariaDB [(none)]> use test_db;
Database changed

文字コードの確認

MariaDB [test_db]> show variables like "chara%";
+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name            | Value                                                                                                                                   |
+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| character_set_client     | utf8mb4                                                                                                                                 |
| character_set_collations | utf8mb3=utf8mb3_uca1400_ai_ci,ucs2=ucs2_uca1400_ai_ci,utf8mb4=utf8mb4_uca1400_ai_ci,utf16=utf16_uca1400_ai_ci,utf32=utf32_uca1400_ai_ci |
| character_set_connection | utf8mb4                                                                                                                                 |
| character_set_database   | utf8mb4                                                                                                                                 |
| character_set_filesystem | binary                                                                                                                                  |
| character_set_results    | utf8mb4                                                                                                                                 |
| character_set_server     | utf8mb4                                                                                                                                 |
| character_set_system     | utf8mb3                                                                                                                                 |
| character_sets_dir       | /usr/share/mariadb/charsets/                                                                                                            |
+--------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
9 rows in set (0.001 sec)

テスト用DBの削除

MariaDB [test_db]> drop database test_db;
Query OK, 0 rows affected (0.012 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.000 sec)

終了

MariaDB [(none)]> quit
Bye



以上の内容はhttps://souiunogaii.hatenablog.com/entry/almalinux96-mariadb118-installより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14