Pdo::_Construct(): Server Sent Charset (255) Unknown to the Client. Please, Report to the Developers

PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers

MySQL 8 changed the default charset to utf8mb4. 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?

SQLSTATE[HY000] [2054] Server sent charset unknown to the client. Please, report to the developers

What version of PHP are you using?

According to PHP's bugtracker, this should be fixed as of 7.0.19, 7.1.5, and 7.2.0.

https://bugs.php.net/bug.php?id=74461

Some answers recommended changing the server charset back to utf8 from utf8mb4, but that is a bad idea. utf8 doesn't support the full range of valid unicode characters, so trying to save a string that contains certain characters (like some sets of emoji) will cause a database error. It is much better to simply upgrade PHP to a more recent version.

Failed to connect to MySQL: Server sent charset unknown to the client. Please, report to the developers - SamplePage.php

Turns out all this work on changing the charset and making sure the charset in the database was set properly was just a dependency on another problem, which was the mysqli extension was not properly installed and enabled. I also upgrade the php version to 7.2, which also may have fixed the issue but I am not entirely sure. Maybe someone can verify what the fix was based on what I had done?

phpMyAdmin errors logging in

Try below things

Set in my.cnf

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


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

Also if you have my.ini both work successful with me.



Related Topics



Leave a reply



Submit