mysql8.0無法給用戶授權或提示You are not allowed to create a user with GRANT、for the right syntax to use near 'identified by xxx'的問題
提示意思是不能用grant創建用戶,mysql8.0以前的版本可以使用grant在授權的時候隱式的創建用戶,8.0以後已經不支持,所以必須先創建用戶,然後再授權,命令如下:
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'Hadoop3!';
Query OK, 0 rows affected (0.04 sec)
mysql> grant all privileges on . to 'root'@'%';
Query OK, 0 rows affected (0.03 sec)
另外,如果遠程連接的時候報plugin caching_sha2_password could not be loaded這個錯誤,可以嘗試修改密碼加密插件:
mysql> alter user 'root'@'%' identified with mysql_native_password by 'Hadoop3!';