ubuntu 24.04 LTSで自宅サーバー構築（MySQL 8.0の設定）

<a href="https://px.a8.net/svt/ejp?a8mat=3ZDGSF+2SMFEY+CO4+60OXE" rel="nofollow">初期費用無料、月額990円から、高速・多機能・高安定レンタルサーバー『エックスサーバー』</a>
<amp-pixel src="https://www19.a8.net/0.gif?a8mat=3ZDGSF+2SMFEY+CO4+60OXE" layout="nodisplay"></amp-pixel>
taisuke@ubuntuserver:~$ sudo apt -y install mysql-server-8.0
taisuke@ubuntuserver:~$ sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36-2ubuntu3 (Ubuntu)
Copyright (c) 2000, 2024, 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.
#root ユーザーのデフォルト認証方式は [auth_socket]
mysql> select user,host,plugin from mysql.user; 
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| debian-sys-maint | localhost | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | auth_socket           |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
#デフォルトの文字セット
mysql> show variables like "chara%"; 
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
#データベース一覧
mysql> show databases; 
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
#[mysql_secure_installation] で実行されていた
#パスワード品質チェックを有効にする場合は以下を実行
#* 無効化する場合は [uninstall component ***]
mysql> install component 'file://component_validate_password'; 
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like 'validate_password%'; 
+-------------------------------------------------+--------+
| Variable_name                                   | Value  |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0      |
| validate_password.check_user_name               | ON     |
| validate_password.dictionary_file               |        |
| validate_password.length                        | 8      |
| validate_password.mixed_case_count              | 1      |
| validate_password.number_count                  | 1      |
| validate_password.policy                        | MEDIUM |
| validate_password.special_char_count            | 1      |
+-------------------------------------------------+--------+
8 rows in set (0.00 sec)
#* チェックポリシーのパラメーターを変更する場合は
#[/etc/mysql/mysql.conf.d/mysqld.cnf] の [mysqld] セクションで設定
#ex. validate_password.policy=LOW
#動作確認として テストデータベース作成
mysql> create database test_database; 
Query OK, 1 row affected (0.11 sec)
#テストデータベースにテストテーブル作成
mysql> create table test_database.test_table (id int, name varchar(50), address varchar(50), primary key (id)); 
Query OK, 0 rows affected (0.42 sec)
#テストテーブルにデータ投入
mysql> insert into test_database.test_table(id, name, address) values("001", "Ubuntu", "Matsuyama"); 
Query OK, 1 row affected (0.04 sec)

#テストテーブル表示
mysql> select * from test_database.test_table; 
+----+--------+-----------+
| id | name   | address   |
+----+--------+-----------+
|  1 | Ubuntu | Matsuyama |
+----+--------+-----------+
1 row in set (0.00 sec)
#テストデータベース削除
mysql> drop database test_database; 
Query OK, 1 row affected (0.27 sec)
mysql> exit
Bye
<a href="https://px.a8.net/svt/ejp?a8mat=3ZDGSF+2SMFEY+CO4+60OXE" rel="nofollow">初期費用無料、月額990円から、高速・多機能・高安定レンタルサーバー『エックスサーバー』</a>
<amp-pixel src="https://www19.a8.net/0.gif?a8mat=3ZDGSF+2SMFEY+CO4+60OXE" layout="nodisplay"></amp-pixel>