Please report to developers: PDO::__construct(): Server-sent charset (255) not recognized by client
P粉808697471
P粉808697471 2023-10-16 10:02:44
0
2
677

I'm trying to connect to a MySQL database from a Symfony 3 application. But when trying to create a MySQL schema from a Symfony console command, I get this error: PDO::__construct(): The server sent a character set (255) unknown to the client. Please report to the developers

Both PHP and MySQL run in Docker containers.

MySQL version: 8.0.1

PHP version: 7.1.3

Driver: pdo_mysql

Character set: UTF8

dsn: "mysql:host=mysql;dbname=database;charset=UTF8;"

Any ideas?

P粉808697471
P粉808697471

reply all(2)
P粉364642019

After upgrading to MySQL 8.0.11, I encountered the same problem as the OP when using PHP's mysqli_connect() function. In my MySQL directory (in my case, usr/local/mysql), I created the my.cnf file, added the content from the accepted answer, and then Restart the MySQL server. However, this produced a new error:

mysqli_connect(): The server requests an authentication method unknown to the client [caching_sha2_password]

I added the line default_authentication_plugin = mysql_native_password, so my.cnf now looks like:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

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

I'm so excited to go!

More references:https://github.com/laradock/laradock/issues/1392

Please note ARA1307’s comment:

"Please note that you should create new users and explicitly specify "IDENTIFIED WITH mysql_native_password", and change existing users, for example: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

P粉884548619

MySQL 8 changes the default character set to utf8mb4. But some customers don't know this character set. So this error is thrown when the server reports its default character set to the client and the client does not know what the server means.

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

This bug is specific to MySQL Connector/C, so it affects more than just PHP.

The correct solution is to upgrade the client, but in the meantime I got it working by changing the server's charset 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 this 2010 answer: Change MySQL default charset in my.cnf to UTF-8?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template