MySQL8 ERROR 1064 (42000) : IDENTIFIED BY 'password' WITH GRANT OPTION'
错误
在云服务安装了MySQL8,设置远程连接,在进行授权操作的时候却出现了错误
# 进行授权操作
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' 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版本已经将创建账户和赋予权限的方式分开了
解决方案
# 创建账户
mysql> GCREATE USER 'root'@'%' IDENTIFIED BY 'password';
# 赋予权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';