MySQL5.7まではいけたGrant文でのCreate User
MySQL5.5
Server version: 5.5.52 MySQL Community Server (GPL) ~ mysql> GRANT ALL ON nanigashi.* TO 'super_nanigashi'@'%' IDENTIFIED BY "super_nanigashi"; Query OK, 0 rows affected (0.01 sec)
MySQL5.7
Server version: 5.7.22 MySQL Community Server (GPL) ~ mysql> GRANT ALL ON nanigashi.* TO 'super_nanigashi'@'%' IDENTIFIED BY "super_nanigashi"; Query OK, 0 rows affected, 1 warning (0.01 sec)
MySQL8からできません。
Server version: 8.0.11 MySQL Community Server - GPL ~ mysql> GRANT ALL ON nanigashi.* TO 'super_nanigashi'@'%' IDENTIFIED BY "super_nanigashi"; 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 "super_nanigashi"' at line 1
ちなみにMySQL8には待望の(?)ROLEができた
Server version: 8.0.11 MySQL Community Server - GPL ~ mysql> CREATE ROLE super_nanigashi_role; Query OK, 0 rows affected (0.20 sec) mysql> GRANT ALL ON nanigashi.* TO super_nanigashi_role; Query OK, 0 rows affected (0.20 sec) mysql> CREATE USER 'super_nanigashi'@'%' IDENTIFIED BY "super_nanigashi" DEFAULT ROLE super_nanigashi_role; Query OK, 0 rows affected (0.04 sec)
一回ロールを作ればあとは CREATE USER文で権限まで振れる形に。