日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2024/9/20 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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”的解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。

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