日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknown to”的解决办法

發布時間:2024/9/20 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknown to”的解决办法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

錯誤信息

SQLSTATE[HY000] [2054] The server requested authentication method unknown to…

這個錯可能是mysql默認使用caching_sha2_password作為默認的身份驗證插件,而不再是mysql_native_password,但是客戶端暫時不支持這個插件導致的。官方文檔說明

In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password. For information about the implications of this change for server operation and compatibility of the server with clients and connectors, see caching_sha2_password as the Preferred Authentication Plugin.

在MySQL 8.0中,caching_sha2_password是默認的身份驗證插件,而不是mysql_native_password。有關此更改對服務器操作的影響以及服務器與客戶端和連接器的兼容性的信息,請參閱caching_sha2_password作為首選身份驗證插件。

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

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

$ vi /etc/my.cnf

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

default_authentication_plugin=mysql_native_password

然后重啟mysql

$ service mysqld restart

解決方法二:修改密碼認證方式

ALTER USER 'YOURUSERNAME'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOURPASSWORD';

官方文檔:https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html

來源:http://blog.haohtml.com/archives/17951

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的PHP连接mysql8.0出错“SQLSTATE[HY000] [2054] The server requested authentication method unknown to”的解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。