mysql8でユーザーに権限を付与

ユーザーの作成や権限に関してmysql8から仕様が変更されているので、手順を記載してみました。
mysqlバージョン
mysql Ver 8.0.17
GRANTでのユーザー作成
MySQL8ではGRANT文でユーザが作成できなくなっている
GRANT ALL ON testdb.* TO 'testuser'@'%' IDENTIFIED BY 'testpassword';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'testpassword'' at line 1
エラーになるので、作成手順を下記に記載
作成手順
まずCREATEしてから、GRANTを実行
mysql> CREATE USER 'testuser'@'%' IDENTIFIED BY 'testpassword';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
-
前の記事
CentOS7でuserをsudoユーザーに追加する方法 2019.09.28
-
次の記事
Mac .bashrcと.bash_profile の作成と編集 2019.09.29
コメントを書く