[Mysql]8.0*版本授權遠程登錄的問題

Mysql拒絕遠程訪問

8.0版本更換了權限設置和密碼加密協議,因此:

mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;

會報出42000錯誤:

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

修正ref

解決方法是:

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL ON db1.* TO 'root'@'%';
mysql> FLUSH PRIVILEGES;

加密協議錯誤

這不是一個安全的方法,但是是向低版本客戶端做妥協的最簡策略。

此外,如果採用了新的加密協議,還需要將密碼進行一次轉譯,否則連接時會有以下報錯:

Fail to connect to MySQL[Error]: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

解決方法:

mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章