では root ユーザにパスワードが設定されていない → root パスワードを変更する ★ root-password の部分には任意の文字列を入力する MySQL のパスワード設定 # mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.30 Source distribution Copyright (c) 2000, 2022, 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. mysql>alter user 'root'@'localhost' identified by 'root-password';
から抜け、ログイン時にパスワード入力が求められるか確認する MySQL のパスワード設定更新確認 # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.30 Source distribution Copyright (c) 2000, 2022, 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.
# mysql -u worduser -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.30 Source distribution Copyright (c) 2000, 2022, 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. mysql> select user(), current_user(); +--------------------+--------------------+ | user() | current_user() | +--------------------+--------------------+ | worduser@localhost | worduser@localhost | +--------------------+--------------------+ 1 row in set (0.00 sec)
ユーザに切り替える 以下コマンドを実行し、作成したユーザーに データベース(wordpress)の全ての権限を付 与する 権限の付与 # mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.30 Source distribution Copyright (c) 2000, 2022, 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. mysql> grant all privileges on wordpress.* to worduser@localhost; Query OK, 0 rows affected (0.01 sec)