MariaDB インストール
sudo apt install mariadb-server
sudo apt install mariadb-server
初期設定は次のコマンドを入力して行います。
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」を入力します。
「 /etc/mysql/mariadb.conf.d 」ディレクトリの中にある次の4つのファイルが設定ファイルです。
文字コードの設定を確認するには次のようにします。
user@user:~$ sudo mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 47
Server version: 10.11.8-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8mb3 |
| character_set_connection | utf8mb3 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb3 |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb3 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.001 sec)