使用 php 5.4 連接 Mysql8 出現錯誤

PHP连接MySQL报错mysql_connect(): Server sent charset (255) unknown to the client.
必須把 mysql.ini裡面所有 utf8mb4 改成 utf8

[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
[client]
port=3306
default-character-set=utf8

後臺運行連接mysql出錯
[ error ] [2054]SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

需要在 mysql.ini 添加設定

[mysqld]
default_authentication_plugin= mysql_native_password
重新啟動生效設置

$ net stop mysql
$ net start mysql
重新啟動後查看設置

$ show variables like "characterset%";
81721-in6apw0366.png

标签: none

添加新评论