筆者が大好きな歌、『メリー・ポピンズ・リターンズ』の『本は表紙じゃ分からない(Cover is not the Book)』に書かれている
Cover is not the book / 心が目に見えないように本も So open it up and take a look / 表紙の美しさに騙されちゃダメ 'Cause under the covers one discovers / 中身読んだらやさしい王様 That the king may be a crook / 詐欺師だとわかるかも
MySQL 8.4以降では、長年使われてきた古い認証方式(mysql_native_password)がデフォルトで無効化され、よりセキュアな caching_sha2_password が標準となっています。そのため、設定ファイル(mysqld.cnf)を書き換えて旧プラグインを強制する手順は不要となり、標準の認証方式のまま初期設定を進めます。
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';
''のpasswordは任意の、強固なものを入力ください。
標準推奨の caching_sha2_password を用いて強固なパスワードを設定します。
flush privileges;
exit
mysql_secure_installation
sudo mysql_secure_installation
質問事項
Enter password for user root: # 上記で設定したパスワードを入力します VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: # パスワード強度チェックを有効にするためYを入力してEnter There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: # ポリシーに合わせて0/1/2を入力(ローカル開発環境なら0または1を推奨) Estimated strength of the password: 50 Change the password for root ? ((Press y|Y for Yes, any other key for No) : # 既に直前の手順でパスワードを設定済みのため、ここではnを選択します。 By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : # anonymousユーザーを削除するためY Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : # rootユーザのリモートログインを禁止するためY Remove test database and access to it? (Press y|Y for Yes, any other key for No) : # テストDBを削除するためY Reload privilege tables now? (Press y|Y for Yes, any other key for No) : # 設定を反映するためY