概要
AmazonLinux2からAmazonLinux2023に乗り換えるべく、同じ環境を作ります。
#環境
- AWS EC2
- OS: Amazon Linux 2023
- AMI: al2023-ami-2023.5.20240730.0-kernel-6.1-x86_64
- RDS
- engine: MySQL Community
- version: 8.0.35
構築手順
こちらの公式情報を参考に進めます。
1. MySQL8.0のリポジトリを追加
最新のリポジトリはこちらで確認します。AL2023はFedoraベースのようですが、構成はRHEL9に似てるらしいのでRHEL9のパッケージを入れてみます。
$ sudo dnf localinstall -y https://dev.mysql.com/get/mysql80-community-release-el9-5.noarch.rpm
Dependencies resolved.
=============================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================
Installing:
mysql80-community-release noarch el9-5 @commandline 13 k
Transaction Summary
=============================================================================================================================================
Install 1 Package
2. MySQL8.0が有効になっているか確認
デフォルトで最新のGAシリーズ(現在のMySQL 8.0)が有効になっているようですが、念のため確認します。
$ dnf repolist enabled | grep mysql
mysql-connectors-community MySQL Connectors Community
mysql-tools-community MySQL Tools Community
mysql80-community MySQL 8.0 Community Server
3. mysql-community-clientをインストール
$ sudo dnf install -y mysql-community-client
Dependencies resolved.
=====================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================
Installing:
mysql-community-client x86_64 8.0.39-1.el9 mysql80-community 3.4 M
Installing dependencies:
mysql-community-client-plugins x86_64 8.0.39-1.el9 mysql80-community 1.4 M
mysql-community-common x86_64 8.0.39-1.el9 mysql80-community 556 k
mysql-community-libs x86_64 8.0.39-1.el9 mysql80-community 1.5 M
Transaction Summary
=====================================================================================================================
Install 4 Packages
$ mysql --version
mysql Ver 8.0.39 for Linux on x86_64 (MySQL Community Server - GPL)
4. 接続確認
セキュリティグループでEC2からRDSへの3306ポートが開いていれば接続できるはずです。
$ mysql -hyour-db.your-region.rds.amazonaws.com -uusername -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 123456
Server version: 8.0.35 Source distribution
Copyright (c) 2000, 2024, 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>