PHP鏈接mysql8.0出錯「SQLSTATE[HY000] [2054] The server requested authentication method unknow.....

這個錯多是mysql默認使用 caching_sha2_password
做爲默認的身份驗證插件,而再也不是 mysql_native_password
,可是客戶端暫時不支持這個插件致使的。mysql

解決方法一:修改MySQL全局配置文件

編輯 my.cnf
文件,更改默認的身份認證插件。sql

$ vi /etc/my.cnf

在 [mysqld]
中添加下邊的代碼插件

default_authentication_plugin=mysql_native_password

而後重啓mysqlrest

$ service mysqld restart
相關文章
相關標籤/搜索