Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers

我的梦境 提交于 2019-12-02 18:13:31

问题


Installed on the local machine Docker and Kohana framework.

I can't establish a connection to the database.

An error occurs:

Database_Exception [ 2 ]: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers

Filу datebase.php

return array

( 'default' => array ( 'type' => 'MySQLi', 'connection' => array( 'hostname' => 'mysql', 'database' => 'media', 'username' => 'root', 'password' => 'root', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' => 'utf8mb4', 'caching' => FALSE,

How to solve this problem?


回答1:


MySQL has changed the default charset to utfmb4 from version 8. But some clients don't know this charset. Hence when the server reports its default charset to the client, and the client doesn't know what the server means, it throws this error.

See also https://bugs.mysql.com/bug.php?id=71606

That bug is against the MySQL Connector/C++ so it's affecting more than just PHP.

Okay - I got it to work by changing the character set to utf8, to be compatible with non-upgraded clients. I added this to /etc/my.cnf and restarted mysqld:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


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

I found these settings in an answer from 2010: Change MySQL default character set to UTF-8 in my.cnf?




回答2:


You can use mysql:5.7 and php:7.3.9 docker images, this seems to work well.

Got this from here:

https://community.atlassian.com/t5/Bitbucket-questions/Pipelines-Server-sent-charset-unknown-to-the-client/qaq-p/780112 and

https://bugs.mysql.com/bug.php?id=85946



来源:https://stackoverflow.com/questions/52111832/database-exception-2-mysqli-connect-server-sent-charset-255-unknown-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!