AlmaLinux9にmysqldをインストール
AlamaLinux9にmysqldをインストールする。mariaDBではなく、また、mysqlの公式サイトからレポジトリを取得しインストールしてみた。公式ダウンロードページにある「MySQL Yum Repository」でファイル名を確認。
https://dev.mysql.com/downloads/repo/yum/
mysql84-community-release-el9-1.noarch.rpm を採用(2025.07.06)
dnf localinstall https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
デフォルトの mysql を無効化
dnf module disable mysql
dnf info mysql-community-server
Last metadata expiration check: 0:07:23 ago on Sun 06 Jul 2025 03:11:51 PM JST.
Installed Packages
Name : mysql-community-server
Version : 8.4.5
Release : 1.el9
Architecture : x86_64
Size : 232 M
Source : mysql-community-8.4.5-1.el9.src.rpm
Repository : @System
From repo : mysql-8.4-lts-community
Summary : A very fast and reliable SQL database server
URL : http://www.mysql.com/
License : Copyright (c) 2000, 2025, Oracle and/or its affiliates. Under
: GPLv2 license as shown in the Description field.
dnf install mysql-community-server
mysqld --version
/usr/sbin/mysqld Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
AlamaLinux9にmysqldをインストールして起動
systemctl enable mysqld
systemctl start mysqld
rootパスワードの確認
head -n 5 /var/log/mysqld.log
2025-07-06T06:13:02.486767Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2025-07-06T06:13:02.488325Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.4.5) initializing of server in progress as process 6477
2025-07-06T06:13:02.499294Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-07-06T06:13:03.576727Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2025-07-06T06:13:05.247425Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: XXXXXXXXXXX ← これがrootの初期パスワード
ログインできるか確認しておこう!
mysql -u root -p
初期設定(前述のrootのパスワードを変更する)
mysql_secure_installation
# rootパスワードを入力
Enter password for user root:
# rootの新しいパスワード
# 英(大小)数記号が混ざってないとダメ
The existing password for the user account root has expired. Please set a new password.
# パスワードの強度 100
Estimated strength of the password: 100
# root のパスワードを変更するか
# はいなら y いいえなら他のキー
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
# 入力したパスワードでOKか?
# はいなら y いいえなら他のキー
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :
# 匿名ユーザーを削除するか?
# はい(削除する)なら 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) : N
# テスト用データベースを削除するか
# はい(削除する)なら y いいえなら他のキー
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N
# 特権テーブルをリロードするか? ( = 設定を確定するか)
# はい(確定する)なら y いいえなら他のキー
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : N
mysqldの設定 /etc/my.cnf
vi /etc/my.cnf
[mysqld]
character-set-server = utf8mb4 # 追加
collation-server = utf8mb4_general_ci # 追加
[client]
default-character-set = utf8mb4
最終適用
systemctl restart mysqld