AlmaLinux9.0にMySQL 8.0.28をインストールする手順

環境
OSバージョンの確認
# cat /etc/redhat-release
AlmaLinux release 9.0 (Emerald Puma)

MySQL8のインストール手順
1.MySQLインストール可能バージョンを確認します
# dnf info mysql
出力結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
利用可能なパッケージ
名前 : mysql
バージョン : 8.0.28
リリース : 1.el9
Arch : x86_64
サイズ : 2.6 M
ソース : mysql-8.0.28-1.el9.src.rpm
リポジトリー : appstream
概要 : MySQL client programs and shared libraries
URL : http://www.mysql.com
ライセンス : GPLv2 with exceptions and LGPLv2 and BSD
説明 : MySQL is a multi-user, multi-threaded SQL database server. MySQL
: is a client/server implementation consisting of a server daemon
: (mysqld) and many different client programs and libraries. The
: base package contains the standard MySQL client programs and
: generic MySQL files.
利用可能なパッケージ 名前 : mysql バージョン : 8.0.28 リリース : 1.el9 Arch : x86_64 サイズ : 2.6 M ソース : mysql-8.0.28-1.el9.src.rpm リポジトリー : appstream 概要 : MySQL client programs and shared libraries URL : http://www.mysql.com ライセンス : GPLv2 with exceptions and LGPLv2 and BSD 説明 : MySQL is a multi-user, multi-threaded SQL database server. MySQL : is a client/server implementation consisting of a server daemon : (mysqld) and many different client programs and libraries. The : base package contains the standard MySQL client programs and : generic MySQL files.
利用可能なパッケージ
名前         : mysql
バージョン   : 8.0.28
リリース     : 1.el9
Arch         : x86_64
サイズ       : 2.6 M
ソース       : mysql-8.0.28-1.el9.src.rpm
リポジトリー : appstream
概要         : MySQL client programs and shared libraries
URL          : http://www.mysql.com
ライセンス   : GPLv2 with exceptions and LGPLv2 and BSD
説明         : MySQL is a multi-user, multi-threaded SQL database server. MySQL
             : is a client/server implementation consisting of a server daemon
             : (mysqld) and many different client programs and libraries. The
             : base package contains the standard MySQL client programs and
             : generic MySQL files.

2.MySQL8をインストールします
# dnf -y install mysql
# dnf -y install mysql-server

3.MySQLバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# mysql --version
mysql Ver 8.0.28 for Linux on x86_64 (Source distribution)
# mysql --version mysql Ver 8.0.28 for Linux on x86_64 (Source distribution)
# mysql --version
mysql  Ver 8.0.28 for Linux on x86_64 (Source distribution)

4.自動起動を設定します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
# sudo systemctl enable --now mysqld Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
# sudo systemctl enable --now  mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

5.MySQL初期設定を行います

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
## 初期設定
mysql_secure_installation
<出力結果>
## パスワードを設定
Press y|Y for Yes, any other key for No: y
## パスワードのポリシー設定2を選択
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
## rootのパスワードの設定
New password: #パスワード入力
Re-enter new password: #パスワード確認
## 設定したパスワードで問題があるかどうか y
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
## 匿名ユーザーは不要 y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
## rootでのリモート接続はさせない y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
## テストDBは不要 y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
## 設定を反映 y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
All done!
## 初期設定 mysql_secure_installation <出力結果> ## パスワードを設定 Press y|Y for Yes, any other key for No: y ## パスワードのポリシー設定2を選択 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 ## rootのパスワードの設定 New password: #パスワード入力 Re-enter new password: #パスワード確認 ## 設定したパスワードで問題があるかどうか y Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y ## 匿名ユーザーは不要 y Remove anonymous users? (Press y|Y for Yes, any other key for No) : y ## rootでのリモート接続はさせない y Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y ## テストDBは不要 y Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y ## 設定を反映 y Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y All done!
## 初期設定
mysql_secure_installation

<出力結果>
## パスワードを設定
Press y|Y for Yes, any other key for No: y

## パスワードのポリシー設定2を選択
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

## rootのパスワードの設定
New password:            #パスワード入力
Re-enter new password:   #パスワード確認

## 設定したパスワードで問題があるかどうか y
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

## 匿名ユーザーは不要 y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

## rootでのリモート接続はさせない y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

## テストDBは不要 y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

## 設定を反映 y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!

6.MySQLサーバーに接続します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# mysql -u root -p
Enter password:  #パスワード入力
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.28 Source distribution
Copyright (c) 2000, 2022, 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>
# mysql -u root -p Enter password:  #パスワード入力 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.28 Source distribution Copyright (c) 2000, 2022, 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>
# mysql -u root -p
Enter password:  #パスワード入力
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.28 Source distribution

Copyright (c) 2000, 2022, 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>

 

AlmaLinux

Posted by arkgame