MySQL 8 新增用户 ERROR 1064 (42000)异常

Scroll Down

MySQL 8 创建用户异常, 报错如下

mysql> GRANT ALL PRIVILEGES ON *.* TO super_user@"%" IDENTIFIED BY 'password' WITH GRANT OPTION;
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 'password' WITH GRANT OPTION' at line 1

原因是 从MySQL 8开始,不再可以使用 GRANT 命令创建用户。
应当使用 CREATE USER 代替,后跟 GRANT 语句
简单说 拆语句

create user super_user@'%' identified by 'password';
GRANT ALL PRIVILEGES ON *.* TO super_user@'%'  WITH GRANT OPTION;