LoginSignup
3
4

More than 1 year has passed since last update.

AWS EC2 AmazonLinux2にMySQL 5.7系をインストールする

Last updated at Posted at 2022-04-13

当記事では、MySQL 5.7.36をインストールします。

各バージョンを選択したい場合は、こちらからrpmファイルのバージョン及びURLを確認して下さい。

 :paperclip: MySQL Product Archives
 https://downloads.mysql.com/archives/community/

以下の手順は、こちらのサイトを参考にしました。

 :paperclip: Amazon Linux 2 で MySQL を使用する
 https://www.acrovision.jp/service/aws/?p=736

以下、実行したコマンドを羅列します。

1. デフォルトでインストールされている MariaDB をアンインストール

command
sudo yum list installed | grep mariadb
sudo yum remove mariadb-libs

2. MySQL公式のyumリポジトリを追加

command
sudo yum localinstall https://dev.mysql.com/get/mysql-community-server-5.7.36-1.el7.x86_64.rpm

3. インストールするバージョンを有効化

command
sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql57-community

ここで、以下のようにGPGキーが無効となっている場合があります。

The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

この場合は、こちらの参考サイトのように、以下のコマンドを実行します。

 :paperclip: [MySQL] アップデート時にGPGキーのエラーで停止してしまう場合
 https://blog.katsubemakito.net/mysql/mysql-update-error-gpg

command
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

4. MySQLのインストールを実行

command
sudo yum install mysql-community-server

5. インストール後、バージョンを確認する

command
mysqld --version

再起動後、サービスとして稼働していることを確認できます。

※ROOTユーザのパスワードは、MySQLのログに出力されています。
 /var/log/mysqld.log

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4