錯誤
在雲服務安裝了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'@'%';
