インストール方法
sudo dnf -y install mariadb mariadb-server
文字コードの設定
設定ファイル「 /etc/my.cnf 」に設定をします。
/etc/my.cnf
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
(2025/03 現在) デフォルトの文字コードの設定 utf8mb4 のため utf8 で設定するよりも utf8mb4 を設定したほうがよいでしょう。
/etc/my.cnf
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
[client]
default-character-set=utf8mb4
MariaDB の起動
sudo systemctl start mariadb
sudo systemctl enable mariadb
MariaDB の初期設定
初期設定は次のコマンドを入力して行います。
sudo mysql_secure_installation
上記のコマンドを入力したあと、次のような内容を聞かれるため、設定をしていきます。
1.「 Enter current Password for root (enter for none): 」は、初めて設定する場合は、そのまま「Enter」を押します。
2.「 Switch to unix_socket authentication [Y/n] 」は unix_socket認証に切り替えるか聞いているので「 Y」を入力します。
3.「 Change the root password? [Y/n] 」は、「 root 」のパスワードを変更するかと聞いているので、「Y」を入力します。
4.パスワードの変更を選択した場合、「 New password: 」と「 Re-enter new password: 」とパスワードの設定を2回入力を求められるため、任意のパスワードを入力します。
5.「 Remove anonymous users? [Y/n] 」は、Anonyomouseユーザーを削除するか聞かれますので、「Y」を入力します。
6.「 Disallow root login remotely? [Y/n] 」は、ネットワークを介してデータベースに root 権限でアクセスできないように聞いているので、「Y」を入力します。
7.「 Remove test database and access to it? [Y/n] 」は、テスト用のデータベースを削除するか聞かれているので、「Y」を入力します。
8.「 Reload privilege tables now? [Y/n] 」は、ユーザー権限のデータベースを再読み込みさせるか聞いているので、「Y」を入力します。