老版本PHP客户端与新版mysql不兼容的问题

错误1: Server sent charset (255) unknown to the client.

解决方案, 添加配置, 到mysqld.cnf

[mysqld]
collation-server=utf8_unicode_ci
character-set-server=utf8
default_authentication_plugin=mysql_native_password

添加配置, 到mysql.cnf (非必须)

[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

错误2: mysqli_connect: authentication method unknown to the client [caching_sha2_password]

解决方案, 执行SQL

ALTER USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'XXX';