MySQLでユーザー追加

mysql> GRANT SELECT , INSERT , UPDATE , DELETE ON *.* TO {userId}@'localhost' IDENTIFIED BY '{password}';
mysql> GRANT SELECT , INSERT , UPDATE , DELETE ON *.* TO {userId}@'127.0.0.1' IDENTIFIED BY '{password}';
mysql> FLUSH PRIVILEGES;

mysql> GRANT ALL ON *.* TO {userId}@'localhost' IDENTIFIED BY '{password}';
mysql> GRANT ALL ON *.* TO {userId}@'127.0.0.1' IDENTIFIED BY '{password}';
mysql> FLUSH PRIVILEGES;

MySQL8からGRANT構文ではユーザーを作れなくなった。

mysql> CREATE USER {userId}@localhost IDENTIFIED BY '{password}';
mysql> CREATE USER {userId}@127.0.0.1 IDENTIFIED BY '{password}';

mysql> GRANT ALL ON {db}.* TO {userId}@localhost;
mysql> GRANT ALL ON {db}.* TO {userId}@127.0.0.1;

mysql> FLUSH PRIVILEGES;