原因
MySQL8更换了默认的服务器字符集了,当前的character-set-server
默认是utf8mb4
,不再是5.x时代的utf8了,这里给出两种解决方案。
方案一:
直接调整MySQL的默认服务器字符集为utf-8,你可以在my.ini中的 [mysqld]
配置节中,设置 character-set-server = utf8
,如图所示:

这种方案实际就是修改MySQL的服务器字符集为utf8,这个字符集和5.x时代是一样的。
方案二:
你是不是用了PHP7.1.X的版本了?那就换一个版本吧,这个版本的PHP在连接MySQL8 utf8mb4 字符集的时候会失败:)
具体的bug信息见 https://bugs.php.net/bug.php?id=74461
PHP 7.1 fails to connect to MySQL 8.0.x because of charset incompatibility with MySQL 8.0’s new default server charset of utf8mb4.
转载请注明:悠然品鉴 » PHP | ThinkPHP:SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers的问题