RHEL7.xにMySQL8 / PostgreSQL15のクライアントをインストールする

問題とその背景

実務上、何らかの事情で古いバージョンのOSを利用しなければならないことがあります。そのような場合に発生する1つの問題がミドルウェアのバージョンです。例えば、対向ノードであるRDSのエンジンが最新のため、古いOSにSQLクライアントの最新のバージョンを指定してインストールしなければならない、というようなケースがそうです。

今回扱うRHEL7ではyumを利用してパッケージを管理しますが、新しいパッケージをインストールする際は、登録しているリポジトリから取得することになります。

古いバージョンのOSの場合、この登録されているリポジトリも古いものとなっているため、インストール可能なミドルウェアも古いバージョンしかない、ということが生じます。

SQLクライアントのバージョンがデータベースサーバのエンジンのバージョンよりも低いことは問題ですので、今回はこれを解決しよう、というわけです。

注:RHEL8以降のバージョンに関しては、今回ご紹介する方法等は別の方法があります。以下ブログが参考になりました。
https://dev.classmethod.jp/articles/rhel8-postgresql15-client/

結論ファースト

解決法はリポジトリを追加することです。
(リポジトリを追加することはセキュリティ上のリスクなどが発生することがあるため、対象のリポジトリが問題ないか調べたり、顧客がいる場合はコンセンサスを事前に得ることが肝要かと思います)

以下では、PostgreSQ, MySQLを例にコマンドを紹介します。

PostgreSQL

PostgreSQL公式のリポジトリを追加します。

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

上記だけでは依存関係で転んでしまいますので、EPELリポジトリも追加します。

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

SQLクライアントパッケージをインストールします。
(今回、検証用の対向DBにAurora PostgreSQLを用意しました。
Auroraの場合、選択可能なPostgreSQLの最新のメジャーバージョンは15でしたので、クライアントもpostgresql15を指定しています。)

sudo yum -y install postgresql15

MySQL

MySQL公式コミュニティのリポジトリを追加します。

sudo yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm

SQLクライアントパッケージをインストールします。
これでmysqlのバージョン8のクライアントパッケージmysql-community-clientとその他(サーバパッケージを除く)がインストールされます)

sudo yum -y install mysql

検証

  • RHEL7.9をインストールしたEC2インスタンスを起動して、検証環境を構築します。
  • 接続確認用にRDS Auroraクラスタを起動します。
  • 検証はPostgreSQLとMySQLの両方を行います。

(以下、筆者簡単のためrootユーザで実行しておりますがTPOをわきまえたユーザで実行すること推奨です。)

PostgreSQL

事前確認

まず、インストール可能なpostgresql15のパッケージ確認してみましょう。
デフォルトだとありません。

[root@ip-10-0-2-18 ~]# yum list postgresql15
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching Packages to list

ついでにpostgresqlも確認してみましょう。
デフォルトだと[Availble Packages]として2つ表示されていますがバージョン9のみです。

[root@ip-10-0-2-18 ~]# yum list postgresql
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Available Packages
postgresql.i686                                                                                9.2.24-9.el7_9                                                                              rhel-7-server-rhui-rpms
postgresql.x86_64                                                                              9.2.24-9.el7_9                                                                              rhel-7-server-rhui-rpms

このままではpostgresql15はインストールできませんので、リポジトリを追加する必要あります。
後から比較するために、現在の登録されているリポジトリを見てみましょう。
(画面見切れていますが、右にスライドすると)右端にstatusのカラムがあるのが分かるかと思います。
このカラムの値がenabledになっているものが登録されておりなおかつ有効化されているものということになります。
後の手順でこのことが問題になることはありませんが、
リポジトリをインストールしてもenabledにならなければそのまま利用することはできませんので、
自分でリポジトリを追加することがある場合などは確認が必要です。

[root@ip-10-0-2-18 ~]# yum repolist all
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                                                                            repo name                                                                                                       status
rhel-7-server-devtools-debug-rhui-rpms/7Server/x86_64                              Red Hat Developer Tools Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                              disabled
rhel-7-server-devtools-rhui-rpms/7Server/x86_64                                    Red Hat Developer Tools RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                    disabled
rhel-7-server-devtools-source-rhui-rpms/7Server/x86_64                             Red Hat Developer Tools Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                             disabled
rhel-7-server-dotnet-rhui-debug-rpms/7Server/x86_64                                dotNET on RHEL Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                       disabled
rhel-7-server-dotnet-rhui-rpms/7Server/x86_64                                      dotNET on RHEL RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                             disabled
rhel-7-server-dotnet-rhui-source-rpms/7Server/x86_64                               dotNET on RHEL Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                      disabled
rhel-7-server-rhui-debug-rpms/7Server/x86_64                                       Red Hat Enterprise Linux 7 Server from RHUI (Debug RPMs)                                                        disabled
rhel-7-server-rhui-extras-debug-rpms/x86_64                                        Red Hat Enterprise Linux 7 Server - Extras from RHUI (Debug RPMs)                                               disabled
rhel-7-server-rhui-extras-rpms/x86_64                                              Red Hat Enterprise Linux 7 Server - Extras from RHUI (RPMs)                                                     disabled
rhel-7-server-rhui-extras-source-rpms/x86_64                                       Red Hat Enterprise Linux 7 Server - Extras from RHUI (Source RPMs)                                              disabled
rhel-7-server-rhui-optional-debug-rpms/7Server/x86_64                              Red Hat Enterprise Linux 7 Server - Optional from RHUI (Debug RPMs)                                             disabled
rhel-7-server-rhui-optional-rpms/7Server/x86_64                                    Red Hat Enterprise Linux 7 Server - Optional from RHUI (RPMs)                                                   disabled
rhel-7-server-rhui-optional-source-rpms/7Server/x86_64                             Red Hat Enterprise Linux 7 Server - Optional from RHUI (Source RPMs)                                            disabled
rhel-7-server-rhui-rh-common-debug-rpms/7Server/x86_64                             Red Hat Enterprise Linux 7 Server - RH Common from RHUI (Debug RPMs)                                            disabled
rhel-7-server-rhui-rh-common-rpms/7Server/x86_64                                   Red Hat Enterprise Linux 7 Server - RH Common from RHUI (RPMs)                                                  enabled:    243
rhel-7-server-rhui-rh-common-source-rpms/7Server/x86_64                            Red Hat Enterprise Linux 7 Server - RH Common from RHUI (Source RPMs)                                           disabled
rhel-7-server-rhui-rpms/7Server/x86_64                                             Red Hat Enterprise Linux 7 Server from RHUI (RPMs)                                                              enabled: 34,135
rhel-7-server-rhui-source-rpms/7Server/x86_64                                      Red Hat Enterprise Linux 7 Server from RHUI (Source RPMs)                                                       disabled
rhel-7-server-rhui-supplementary-debug-rpms/7Server/x86_64                         Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (Debug RPMs)                                        disabled
rhel-7-server-rhui-supplementary-rpms/7Server/x86_64                               Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (RPMs)                                              disabled
rhel-7-server-rhui-supplementary-source-rpms/7Server/x86_64                        Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (Source RPMs)                                       disabled
rhel-server-rhui-rhscl-7-debug-rpms/7Server/x86_64                                 Red Hat Software Collections Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                         disabled
rhel-server-rhui-rhscl-7-rpms/7Server/x86_64                                       Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server from RHUI                               disabled
rhel-server-rhui-rhscl-7-source-rpms/7Server/x86_64                                Red Hat Software Collections Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                        disabled
rhui-client-config-server-7/x86_64                                                 RHUI Client Configuration Server 7                                                                              enabled:     14
repolist: 34,392

インストール

ではいよいよpostgresql15用にレポジトリをインストールしてみたいと思います。
先ずはPostgreSQLの公式リポジトリです。
最後にComplete!と表示されればOKです。

[root@ip-10-0-2-18 ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

pgdg-redhat-repo-latest.noarch.rpm                                                                                                                                                         |  10 kB  00:00:00
Examining /var/tmp/yum-root-sD0wpm/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-38PGDG.noarch
Marking /var/tmp/yum-root-sD0wpm/pgdg-redhat-repo-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-38PGDG will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                           Arch                                    Version                                         Repository                                                        Size
==================================================================================================================================================================================================================
Installing:
 pgdg-redhat-repo                                  noarch                                  42.0-38PGDG                                     /pgdg-redhat-repo-latest.noarch                                   12 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package

Total size: 12 k
Installed size: 12 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pgdg-redhat-repo-42.0-38PGDG.noarch                                                                                                                                                            1/1
  Verifying  : pgdg-redhat-repo-42.0-38PGDG.noarch                                                                                                                                                            1/1
rhel-7-server-rhui-rpms/7Server/x86_64/productid                                                                                                                                           | 2.1 kB  00:00:00

Installed:
  pgdg-redhat-repo.noarch 0:42.0-38PGDG

Complete!

ちゃんとComplete!と表示されました。
次にEPELのリポジトリをインストールします。

[root@ip-10-0-2-18 ~]# yum repolist
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

pgdg-common/7Server/x86_64/signature                                                                                                                                                       |  665 B  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (@/pgdg-redhat-repo-latest.noarch)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Is this ok [y/N]: y
pgdg-common/7Server/x86_64/signature                                                                                                                                                       | 2.9 kB  00:00:08 !!!
pgdg12/7Server/x86_64/signature                                                                                                                                                            |  661 B  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (@/pgdg-redhat-repo-latest.noarch)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Is this ok [y/N]:
pgdg12/7Server/x86_64/signature                                                                                                                                                            | 3.6 kB  00:00:01 !!!
https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno -1] Gpg Keys not imported, cannot verify repomd.xml for repo pgdg12
Trying other mirror.

^Cdg-common/7Server/x86_64/primary_db                                                      0% [                                                                                 ]  0.0 B/s |    0 B  --:--:-- ETA

Exiting on user cancel
[root@ip-10-0-2-18 ~]#
[root@ip-10-0-2-18 ~]#
[root@ip-10-0-2-18 ~]#
[root@ip-10-0-2-18 ~]# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

epel-release-latest-7.noarch.rpm                                                                                                                                                           |  15 kB  00:00:00
Examining /var/tmp/yum-root-sD0wpm/epel-release-latest-7.noarch.rpm: epel-release-7-14.noarch
Marking /var/tmp/yum-root-sD0wpm/epel-release-latest-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-14 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                           Arch                                        Version                                   Repository                                                          Size
==================================================================================================================================================================================================================
Installing:
 epel-release                                      noarch                                      7-14                                      /epel-release-latest-7.noarch                                       25 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package

Total size: 25 k
Installed size: 25 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-14.noarch                                                                                                                                                                       1/1
  Verifying  : epel-release-7-14.noarch                                                                                                                                                                       1/1
pgdg12/7Server/x86_64/signature                                                                                                                                                            |  661 B  00:00:00
pgdg12/7Server/x86_64/signature                                                                                                                                                            | 3.6 kB  00:00:00 !!!
https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg12
Trying other mirror.
pgdg13/7Server/x86_64/signature                                                                                                                                                            |  665 B  00:00:00
pgdg13/7Server/x86_64/signature                                                                                                                                                            | 3.6 kB  00:00:00 !!!
https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg13
Trying other mirror.
pgdg14/7Server/x86_64/signature                                                                                                                                                            |  665 B  00:00:00
pgdg14/7Server/x86_64/signature                                                                                                                                                            | 3.6 kB  00:00:00 !!!
https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg14
Trying other mirror.
pgdg15/7Server/x86_64/signature                                                                                                                                                            |  665 B  00:00:00
pgdg15/7Server/x86_64/signature                                                                                                                                                            | 3.6 kB  00:00:00 !!!
https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for pgdg15
Trying other mirror.

Installed:
  epel-release.noarch 0:7-14

Complete!

こちらもOKですね。

では、リポジトリを確認してみましょう。
以下のリポジトリが追加されており、かつ、それぞれにひとつずつsutatusがenabledになっていることが確認できます。
(pgdgはPostgreSQLのパッケージになり、ナンバリングされているのはバージョンを示しています)
epel*
pgdg-*
pgdg12*
pgdg13*
pgdg14*
pgdg15*

[root@ip-10-0-2-18 ~]# yum -y repolist all
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                                                                         repo name                                                                                                          status
epel/x86_64                                                                     Extra Packages for Enterprise Linux 7 - x86_64                                                                     enabled: 13,789
epel-debuginfo/x86_64                                                           Extra Packages for Enterprise Linux 7 - x86_64 - Debug                                                             disabled
epel-source/x86_64                                                              Extra Packages for Enterprise Linux 7 - x86_64 - Source                                                            disabled
epel-testing/x86_64                                                             Extra Packages for Enterprise Linux 7 - Testing - x86_64                                                           disabled
epel-testing-debuginfo/x86_64                                                   Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Debug                                                   disabled
epel-testing-source/x86_64                                                      Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Source                                                  disabled
pgdg-common/7Server/x86_64                                                      PostgreSQL common RPMs for RHEL / CentOS 7Server - x86_64                                                          enabled:    515
pgdg-common-srpm-testing/7Server/x86_64                                         PostgreSQL common testing SRPMs for RHEL / CentOS 7Server - x86_64                                                 disabled
pgdg-common-testing/7Server/x86_64                                              PostgreSQL common testing RPMs for RHEL / CentOS 7Server - x86_64                                                  disabled
pgdg-rhel7-extras/7Server/x86_64                                                Extra packages to support some RPMs in the PostgreSQL RPM repo RHEL / CentOS 7Server - x86_64                      disabled
pgdg-source-common/7Server/x86_64                                               PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Source                                                          disabled
pgdg12/7Server/x86_64                                                           PostgreSQL 12 for RHEL / CentOS 7Server - x86_64                                                                   enabled:  1,294
pgdg12-debuginfo/7Server/x86_64                                                 PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg12-source/7Server/x86_64                                                    PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Source                                                          disabled
pgdg12-source-updates-testing/7Server/x86_64                                    PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Source update testing                                           disabled
pgdg12-updates-testing/7Server/x86_64                                           PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Updates testing                                                 disabled
pgdg12-updates-testing-debuginfo/7Server/x86_64                                 PostgreSQL 12 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg13/7Server/x86_64                                                           PostgreSQL 13 for RHEL / CentOS 7Server - x86_64                                                                   enabled:  1,054
pgdg13-debuginfo/7Server/x86_64                                                 PostgreSQL 13 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg13-source/7Server/x86_64                                                    PostgreSQL 13 for RHEL / CentOS 7Server - x86_64 - Source                                                          disabled
pgdg13-source-updates-testing/7Server/x86_64                                    PostgreSQL 13 for RHEL / CentOS 7Server - x86_64 - Source updates testing                                          disabled
pgdg13-updates-testing/7Server/x86_64                                           PostgreSQL 13 for RHEL / CentOS 7Server - x86_64 - Updates testing                                                 disabled
pgdg13-updates-testing-debuginfo/7Server/x86_64                                 PostgreSQL 13 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg14/7Server/x86_64                                                           PostgreSQL 14 for RHEL / CentOS 7Server - x86_64                                                                   enabled:    798
pgdg14-debuginfo/7Server/x86_64                                                 PostgreSQL 14 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg14-source/7Server/x86_64                                                    PostgreSQL 14 for RHEL / CentOS 7Server - x86_64 - Source                                                          disabled
pgdg14-source-updates-testing/7Server/x86_64                                    PostgreSQL 14 for RHEL / CentOS 7Server - x86_64 - Source updates testing                                          disabled
pgdg14-updates-testing/7Server/x86_64                                           PostgreSQL 14 for RHEL / CentOS 7Server - x86_64 - Updates testing                                                 disabled
pgdg14-updates-testing-debuginfo/7Server/x86_64                                 PostgreSQL 14 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg15/7Server/x86_64                                                           PostgreSQL 15 for RHEL / CentOS 7Server - x86_64                                                                   enabled:    509
pgdg15-debuginfo/7Server/x86_64                                                 PostgreSQL 15 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
pgdg15-source/7Server/x86_64                                                    PostgreSQL 15 for RHEL / CentOS 7Server - x86_64 - Source                                                          disabled
pgdg15-source-updates-testing/7Server/x86_64                                    PostgreSQL 15 for RHEL / CentOS 7Server - x86_64 - Source updates testing                                          disabled
pgdg15-updates-testing/7Server/x86_64                                           PostgreSQL 15 for RHEL / CentOS 7Server - x86_64 - Updates testing                                                 disabled
pgdg15-updates-testing-debuginfo/7Server/x86_64                                 PostgreSQL 15 for RHEL / CentOS 7Server - x86_64 - Debuginfo                                                       disabled
rhel-7-server-devtools-debug-rhui-rpms/7Server/x86_64                           Red Hat Developer Tools Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                 disabled
rhel-7-server-devtools-rhui-rpms/7Server/x86_64                                 Red Hat Developer Tools RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                       disabled
rhel-7-server-devtools-source-rhui-rpms/7Server/x86_64                          Red Hat Developer Tools Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                disabled
rhel-7-server-dotnet-rhui-debug-rpms/7Server/x86_64                             dotNET on RHEL Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                          disabled
rhel-7-server-dotnet-rhui-rpms/7Server/x86_64                                   dotNET on RHEL RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                                disabled
rhel-7-server-dotnet-rhui-source-rpms/7Server/x86_64                            dotNET on RHEL Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                         disabled
rhel-7-server-rhui-debug-rpms/7Server/x86_64                                    Red Hat Enterprise Linux 7 Server from RHUI (Debug RPMs)                                                           disabled
rhel-7-server-rhui-extras-debug-rpms/x86_64                                     Red Hat Enterprise Linux 7 Server - Extras from RHUI (Debug RPMs)                                                  disabled
rhel-7-server-rhui-extras-rpms/x86_64                                           Red Hat Enterprise Linux 7 Server - Extras from RHUI (RPMs)                                                        disabled
rhel-7-server-rhui-extras-source-rpms/x86_64                                    Red Hat Enterprise Linux 7 Server - Extras from RHUI (Source RPMs)                                                 disabled
rhel-7-server-rhui-optional-debug-rpms/7Server/x86_64                           Red Hat Enterprise Linux 7 Server - Optional from RHUI (Debug RPMs)                                                disabled
rhel-7-server-rhui-optional-rpms/7Server/x86_64                                 Red Hat Enterprise Linux 7 Server - Optional from RHUI (RPMs)                                                      disabled
rhel-7-server-rhui-optional-source-rpms/7Server/x86_64                          Red Hat Enterprise Linux 7 Server - Optional from RHUI (Source RPMs)                                               disabled
rhel-7-server-rhui-rh-common-debug-rpms/7Server/x86_64                          Red Hat Enterprise Linux 7 Server - RH Common from RHUI (Debug RPMs)                                               disabled
rhel-7-server-rhui-rh-common-rpms/7Server/x86_64                                Red Hat Enterprise Linux 7 Server - RH Common from RHUI (RPMs)                                                     enabled:    243
rhel-7-server-rhui-rh-common-source-rpms/7Server/x86_64                         Red Hat Enterprise Linux 7 Server - RH Common from RHUI (Source RPMs)                                              disabled
rhel-7-server-rhui-rpms/7Server/x86_64                                          Red Hat Enterprise Linux 7 Server from RHUI (RPMs)                                                                 enabled: 34,135
rhel-7-server-rhui-source-rpms/7Server/x86_64                                   Red Hat Enterprise Linux 7 Server from RHUI (Source RPMs)                                                          disabled
rhel-7-server-rhui-supplementary-debug-rpms/7Server/x86_64                      Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (Debug RPMs)                                           disabled
rhel-7-server-rhui-supplementary-rpms/7Server/x86_64                            Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (RPMs)                                                 disabled
rhel-7-server-rhui-supplementary-source-rpms/7Server/x86_64                     Red Hat Enterprise Linux 7 Server - Supplementary from RHUI (Source RPMs)                                          disabled
rhel-server-rhui-rhscl-7-debug-rpms/7Server/x86_64                              Red Hat Software Collections Debug RPMs for Red Hat Enterprise Linux 7 Server from RHUI                            disabled
rhel-server-rhui-rhscl-7-rpms/7Server/x86_64                                    Red Hat Software Collections RPMs for Red Hat Enterprise Linux 7 Server from RHUI                                  disabled
rhel-server-rhui-rhscl-7-source-rpms/7Server/x86_64                             Red Hat Software Collections Source RPMs for Red Hat Enterprise Linux 7 Server from RHUI                           disabled
rhui-client-config-server-7/x86_64                                              RHUI Client Configuration Server 7                                                                                 enabled:     14
repolist: 52,351

postgresql15パッケージが含まれるリポジトリが有効化されていますので、このままSQLクライアントをインストールしたいと思います。

[root@ip-10-0-2-18 ~]# yum -y install postgresql15
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Resolving Dependencies
--> Running transaction check
---> Package postgresql15.x86_64 0:15.5-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql15-libs(x86-64) = 15.5-1PGDG.rhel7 for package: postgresql15-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libzstd >= 1.4.0 for package: postgresql15-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libicu for package: postgresql15-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libzstd.so.1()(64bit) for package: postgresql15-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql15-15.5-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package libicu.x86_64 0:50.2-4.el7_7 will be installed
---> Package libzstd.x86_64 0:1.5.5-1.el7 will be installed
---> Package postgresql15-libs.x86_64 0:15.5-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                             Arch                                     Version                                             Repository                                                 Size
==================================================================================================================================================================================================================
Installing:
 postgresql15                                        x86_64                                   15.5-1PGDG.rhel7                                    pgdg15                                                    1.6 M
Installing for dependencies:
 libicu                                              x86_64                                   50.2-4.el7_7                                        rhel-7-server-rhui-rpms                                   6.9 M
 libzstd                                             x86_64                                   1.5.5-1.el7                                         epel                                                      292 k
 postgresql15-libs                                   x86_64                                   15.5-1PGDG.rhel7                                    pgdg15                                                    285 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 9.0 M
Installed size: 34 M
Downloading packages:
(1/4): libicu-50.2-4.el7_7.x86_64.rpm                                                                                                                                                      | 6.9 MB  00:00:00
warning: /var/cache/yum/x86_64/7Server/pgdg15/packages/postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 73e3b907: NOKEY====-                 ] 179 kB/s | 7.1 MB  00:00:11 ETA
Public key for postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm is not installed
(2/4): postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm                                                                                                                                       | 285 kB  00:00:01
(3/4): postgresql15-15.5-1PGDG.rhel7.x86_64.rpm                                                                                                                                            | 1.6 MB  00:00:01
warning: /var/cache/yum/x86_64/7Server/epel/packages/libzstd-1.5.5-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for libzstd-1.5.5-1.el7.x86_64.rpm is not installed
(4/4): libzstd-1.5.5-1.el7.x86_64.rpm                                                                                                                                                      | 292 kB  00:00:02
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                             3.8 MB/s | 9.0 MB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (@/pgdg-redhat-repo-latest.noarch)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-14.noarch (@/epel-release-latest-7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libicu-50.2-4.el7_7.x86_64                                                                                                                                                                     1/4
  Installing : libzstd-1.5.5-1.el7.x86_64                                                                                                                                                                     2/4
  Installing : postgresql15-libs-15.5-1PGDG.rhel7.x86_64                                                                                                                                                      3/4
  Installing : postgresql15-15.5-1PGDG.rhel7.x86_64                                                                                                                                                           4/4
  Verifying  : postgresql15-libs-15.5-1PGDG.rhel7.x86_64                                                                                                                                                      1/4
  Verifying  : libzstd-1.5.5-1.el7.x86_64                                                                                                                                                                     2/4
  Verifying  : postgresql15-15.5-1PGDG.rhel7.x86_64                                                                                                                                                           3/4
  Verifying  : libicu-50.2-4.el7_7.x86_64                                                                                                                                                                     4/4

Installed:
  postgresql15.x86_64 0:15.5-1PGDG.rhel7

Dependency Installed:
  libicu.x86_64 0:50.2-4.el7_7                                    libzstd.x86_64 0:1.5.5-1.el7                                    postgresql15-libs.x86_64 0:15.5-1PGDG.rhel7

Complete!

Complete!と表示されましたので上手く生きましたね。

余談ですが、上記の出力結果を見てみると、postgresql15のパッケージとその依存関係に必要なパッケージがどのリポジトリから取得されているのかが分かります。
以下は抜粋ですが、Repositoryのカラムを見ると、今回インストールしたEPELとpgdg15が利用されていることが見てとれるかと思います。

==================================================================================================================================================================================================================
 Package                                             Arch                                     Version                                             Repository                                                 Size
==================================================================================================================================================================================================================
Installing:
 postgresql15                                        x86_64                                   15.5-1PGDG.rhel7                                    pgdg15                                                    1.6 M
Installing for dependencies:
 libicu                                              x86_64                                   50.2-4.el7_7                                        rhel-7-server-rhui-rpms                                   6.9 M
 libzstd                                             x86_64                                   1.5.5-1.el7                                         epel                                                      292 k
 postgresql15-libs                                   x86_64                                   15.5-1PGDG.rhel7                                    pgdg15                                                    285 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

さて、インストールできたバージョンをpsqlコマンドで確認してみます。バージョン15.5がインストールされていることが確認できます。

[root@ip-10-0-2-18 ~]# psql -V
psql (PostgreSQL) 15.5

RDSへの接続確認

RDSとの接続確認も行います。
予め用意したAuroraクラスターに接続するよう、以下コマンドを実行します。プロンプトがpostgres=>に変わったら接続OKです。
(今回、データベース名はデフォルトで存在するpostgresを指定してみます)

psql -U [ユーザー名] -h [ホスト名] -d [データベース名]
[root@ip-10-0-2-18 ~]# psql -U hogehoge -h tom-cluster-postgresql.cluster-cowupzjjocwm.ap-northeast-1.rds.amazonaws.com -d postgresPassword for user hogehoge:
psql (15.5, server 15.3)
SSL connection (protocol: TLSv1.2, cipher: AES128-SHA256, compression: off)
Type "help" for help.

postgres=>

無事接続できました。

MySQL

事前確認

続いて、MySQLです。
公式によると、クライアントのパッケージ はmysql-community-clientというパッケージにあるようなのですが、デフォルトではインストールできません。

[root@ip-10-0-2-18 ~]# yum list mysql-community-client
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: No matching Packages to list

もちろんインストールもされていません。

rpm -qa | grep mysql

余談ですが、mysqlの兄弟のmariadbならあります(今回は使いません)。

[root@ip-10-0-2-18 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64

インストール

このままではmysqlのクライアントパッケージをインストールできないことが分かりましたので、例のごとくリポジトリを追加したいと思います。
追加するのは公式 MySQLコミュニティ・リポジトリです。

[root@ip-10-0-2-18 ~]# yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

mysql80-community-release-el7-7.noarch.rpm                                                                                                                                                 |  11 kB  00:00:00
Examining /var/tmp/yum-root-sD0wpm/mysql80-community-release-el7-7.noarch.rpm: mysql80-community-release-el7-7.noarch
Marking /var/tmp/yum-root-sD0wpm/mysql80-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                                  Arch                                  Version                              Repository                                                              Size
==================================================================================================================================================================================================================
Installing:
 mysql80-community-release                                noarch                                el7-7                                /mysql80-community-release-el7-7.noarch                                 10 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package

Total size: 10 k
Installed size: 10 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql80-community-release-el7-7.noarch                                                                                                                                                         1/1
  Verifying  : mysql80-community-release-el7-7.noarch                                                                                                                                                         1/1

Installed:
  mysql80-community-release.noarch 0:el7-7

Complete!

リポジトリを確認してみます。
今回はmysqlに絞って表示します。
mysqlのリポジトリがちゃんと追加されていますね。
とりわけて、mysql80-community/x86_64 がenabledになっていることも確認できます。

[root@ip-10-0-2-18 ~]# yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64                          MySQ disabled
mysql-cluster-7.5-community-source                          MySQ disabled
mysql-cluster-7.6-community/x86_64                          MySQ disabled
mysql-cluster-7.6-community-source                          MySQ disabled
mysql-cluster-8.0-community/x86_64                          MySQ disabled
mysql-cluster-8.0-community-debuginfo/x86_64                MySQ disabled
mysql-cluster-8.0-community-source                          MySQ disabled
mysql-connectors-community/x86_64                           MySQ enabled:    234
mysql-connectors-community-debuginfo/x86_64                 MySQ disabled
mysql-connectors-community-source                           MySQ disabled
mysql-tools-community/x86_64                                MySQ enabled:    102
mysql-tools-community-debuginfo/x86_64                      MySQ disabled
mysql-tools-community-source                                MySQ disabled
mysql-tools-preview/x86_64                                  MySQ disabled
mysql-tools-preview-source                                  MySQ disabled
mysql57-community/x86_64                                    MySQ disabled
mysql57-community-source                                    MySQ disabled
mysql80-community/x86_64                                    MySQ enabled:    446
mysql80-community-debuginfo/x86_64                          MySQ disabled
mysql80-community-source                                    MySQ disabled

リポジトリが有効になっていることが確認できたので、
mysqlをクライアントパッケージをインストールしたいと思います。
パッケージをmysqlで指定するとserverパッケージを除いたパッケージ群をインストールすることが可能です。

[root@ip-10-0-2-122 ~]# yum -y install mysql
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

mysql-connectors-community                                                                                                                                                                 | 2.6 kB  00:00:00
mysql-tools-community                                                                                                                                                                      | 2.6 kB  00:00:00
mysql80-community                                                                                                                                                                          | 2.6 kB  00:00:00
rhel-7-server-rhui-rh-common-rpms                                                                                                                                                          | 3.8 kB  00:00:00
rhel-7-server-rhui-rpms                                                                                                                                                                    | 3.5 kB  00:00:00
rhui-client-config-server-7                                                                                                                                                                | 1.5 kB  00:00:00
(1/10): mysql-connectors-community/x86_64/primary_db                                                                                                                                       | 102 kB  00:00:00
(2/10): mysql-tools-community/x86_64/primary_db                                                                                                                                            |  95 kB  00:00:00
(3/10): mysql80-community/x86_64/primary_db                                                                                                                                                | 266 kB  00:00:00
(4/10): rhel-7-server-rhui-rh-common-rpms/7Server/x86_64/group                                                                                                                             |  124 B  00:00:00
(5/10): rhel-7-server-rhui-rh-common-rpms/7Server/x86_64/updateinfo                                                                                                                        |  34 kB  00:00:00
(6/10): rhel-7-server-rhui-rh-common-rpms/7Server/x86_64/primary_db                                                                                                                        | 119 kB  00:00:00
(7/10): rhel-7-server-rhui-rpms/7Server/x86_64/group                                                                                                                                       | 631 kB  00:00:00
(8/10): rhel-7-server-rhui-rpms/7Server/x86_64/updateinfo                                                                                                                                  | 4.3 MB  00:00:00
(9/10): rhui-client-config-server-7/x86_64/primary                                                                                                                                         | 2.6 kB  00:00:00
(10/10): rhel-7-server-rhui-rpms/7Server/x86_64/primary_db                                                                                                                                 |  93 MB  00:00:01
rhui-client-config-server-7                                                                                                                                                                                 14/14
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.35-1.el7 will be installed
--> Processing Dependency: mysql-community-client-plugins = 8.0.35-1.el7 for package: mysql-community-client-8.0.35-1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.35-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
---> Package mysql-community-client-plugins.x86_64 0:8.0.35-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.35-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) >= 8.0.11 for package: mysql-community-libs-8.0.35-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-common.x86_64 0:8.0.35-1.el7 will be installed
---> Package mysql-community-libs-compat.x86_64 0:8.0.35-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                                         Arch                                    Version                                         Repository                                          Size
==================================================================================================================================================================================================================
Installing:
 mysql-community-client                                          x86_64                                  8.0.35-1.el7                                    mysql80-community                                   16 M
 mysql-community-libs                                            x86_64                                  8.0.35-1.el7                                    mysql80-community                                  1.5 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat                                     x86_64                                  8.0.35-1.el7                                    mysql80-community                                  669 k
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
Installing for dependencies:
 mysql-community-client-plugins                                  x86_64                                  8.0.35-1.el7                                    mysql80-community                                  3.5 M
 mysql-community-common                                          x86_64                                  8.0.35-1.el7                                    mysql80-community                                  665 k

Transaction Summary
==================================================================================================================================================================================================================
Install  3 Packages (+2 Dependent packages)

Total download size: 22 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/mysql80-community/packages/mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Public key for mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm is not installed
(1/5): mysql-community-client-plugins-8.0.35-1.el7.x86_64.rpm                                                                                                                              | 3.5 MB  00:00:00
(2/5): mysql-community-common-8.0.35-1.el7.x86_64.rpm                                                                                                                                      | 665 kB  00:00:00
(3/5): mysql-community-libs-8.0.35-1.el7.x86_64.rpm                                                                                                                                        | 1.5 MB  00:00:00
(4/5): mysql-community-libs-compat-8.0.35-1.el7.x86_64.rpm                                                                                                                                 | 669 kB  00:00:00
(5/5): mysql-community-client-8.0.35-1.el7.x86_64.rpm                                                                                                                                      |  16 MB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                              53 MB/s |  22 MB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: 859b e8d7 c586 f538 430b 19c2 467b 942d 3a79 bd29
 Package    : mysql80-community-release-el7-7.noarch (@/mysql80-community-release-el7-7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql80-community-release-el7-7.noarch (@/mysql80-community-release-el7-7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-client-plugins-8.0.35-1.el7.x86_64                                                                                                                                             1/6
  Installing : mysql-community-common-8.0.35-1.el7.x86_64                                                                                                                                                     2/6
  Installing : mysql-community-libs-8.0.35-1.el7.x86_64                                                                                                                                                       3/6
  Installing : mysql-community-libs-compat-8.0.35-1.el7.x86_64                                                                                                                                                4/6
  Installing : mysql-community-client-8.0.35-1.el7.x86_64                                                                                                                                                     5/6
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                                             6/6
  Verifying  : mysql-community-client-plugins-8.0.35-1.el7.x86_64                                                                                                                                             1/6
  Verifying  : mysql-community-common-8.0.35-1.el7.x86_64                                                                                                                                                     2/6
  Verifying  : mysql-community-libs-compat-8.0.35-1.el7.x86_64                                                                                                                                                3/6
  Verifying  : mysql-community-libs-8.0.35-1.el7.x86_64                                                                                                                                                       4/6
  Verifying  : mysql-community-client-8.0.35-1.el7.x86_64                                                                                                                                                     5/6
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                                                             6/6
rhel-7-server-rhui-rpms/7Server/x86_64/productid                                                                                                                                           | 2.1 kB  00:00:00

Installed:
  mysql-community-client.x86_64 0:8.0.35-1.el7                        mysql-community-libs.x86_64 0:8.0.35-1.el7                        mysql-community-libs-compat.x86_64 0:8.0.35-1.el7

Dependency Installed:
  mysql-community-client-plugins.x86_64 0:8.0.35-1.el7                                                        mysql-community-common.x86_64 0:8.0.35-1.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7

Complete!

Complete!いただきました。

以下は出力の抜粋ですが、postgresqlの時と同じように、今回インストールしたパッケージにリポジトリmysql80-community/x86_64が利用されていることが見てとれるかと思います。
また、mariadbがreplaceされたとあります。mysqlとmariadbは競合してしまうため、yumが自動でその問題を解消してくれたようです。

==================================================================================================================================================================================================================
 Package                                                         Arch                                    Version                                         Repository                                          Size
==================================================================================================================================================================================================================
Installing:
 mysql-community-client                                          x86_64                                  8.0.35-1.el7                                    mysql80-community                                   16 M
 mysql-community-libs                                            x86_64                                  8.0.35-1.el7                                    mysql80-community                                  1.5 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 mysql-community-libs-compat                                     x86_64                                  8.0.35-1.el7                                    mysql80-community                                  669 k
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
Installing for dependencies:
 mysql-community-client-plugins                                  x86_64                                  8.0.35-1.el7                                    mysql80-community                                  3.5 M
 mysql-community-common                                          x86_64                                  8.0.35-1.el7                                    mysql80-community                                  665 k

Transaction Summary
==================================================================================================================================================================================================================
Install  3 Packages (+2 Dependent packages)

念のためmariadbがないか確認してみますが、たしかに消えてなくなりました。

[root@ip-10-0-2-18 ~]# rpm -qa | grep mariadb
[root@ip-10-0-2-18 ~]#

さて、mysqlがインストールできたかも確認してみます。
バージョン8の最新がインストールできています。

[root@ip-10-0-2-18 ~]# mysql -V
mysql  Ver 8.0.35 for Linux on x86_64 (MySQL Community Server - GPL)

RDSへの接続確認

接続確認もしたいともいます。プロンプトがmysql>に変われば接続成功です。結果、うまくいきました。

mysql -u [ユーザー名] -p(=パスワード強制) -h [ホスト名]
[root@ip-10-0-2-18 ~]# mysql -u fugafuga -p -h tom-cluster-mysql.cluster-cowupzjjocwm.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 834
Server version: 8.0.28 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

おわりに

今回は、古いバージョンのOSにsqlクライアント用のパッケージをインストールする方法を紹介しました。
方法そのものはググればわかることだと思う一方、一番の学びは何かと考えたとき、それは次回以降の検討や計画段階でこれらの問題を予め考慮して仕事を進めることができることだと思います。
今回は小さな問題ではありましたが、一事が万事かと思います。
予め様々なリスクを洗い出し、対応の方針やリカバリーの手法を用意することが、プロジェクト成功の可能性をあげる一つの要因だと捉え、経験とともにこうしたナレッジをどんどん蓄積していきたいですね。
それではまたお会いしましょう。
あでゅー!

参考

PostgreSQL15用のリポジトリのインストール方法が参考になりました。
https://ja.linux-console.net/?p=20521

MySQL8.0用のリポジトリのインストール方法が参考になりました。
https://ja.linux-console.net/?p=22128

MySQLクライアントのインストール方法が参考になりました。
https://www.bytebase.com/blog/how-to-install-mysql-client-on-mac-ubuntu-centos-windows/

MySQLの公式です。
クライアントパッケージが何という名前か調べるのに参考になりました。
https://dev.mysql.com/doc/refman/8.0/ja/linux-installation-yum-repo.html

yumのリポジトリ操作が参考になりました。
https://onoredekaiketsu.com/yum-command-and-repository/#toc15

yumリポジトリの設定ファイルの見方が参考になりました。
https://kazmax.zpp.jp/linux_beginner/yum_repository.html

yum localinstallとyum installの違いについて参考になりました。
https://qiita.com/mashiro_lain/items/c37ab3e33e244784bd2f

Last modified: 2024-01-08

Author