Home > Database > Mysql Tutorial > Why Does My Symfony 3 App Get a 'PDO::__construct(): Server sent charset (255) unknown to the client' Error When Connecting to MySQL 8?

Why Does My Symfony 3 App Get a 'PDO::__construct(): Server sent charset (255) unknown to the client' Error When Connecting to MySQL 8?

DDD
Release: 2024-12-16 19:49:19
Original
160 people have browsed it

Why Does My Symfony 3 App Get a

PHP Error: Server Sent Unknown Charset (255) for PDO Connection

When attempting to establish a database connection using PDO in a Symfony 3 application, developers may encounter the following error:

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

Root Cause:

This error arises when the MySQL server, running version 8.0.1 or later, reports its default character set (utf8mb4) which is not recognized by the client, such as PHP running version 7.1.3 with PDO MySQL driver.

Solution:

The ideal remedy is to update the client. However, as a temporary workaround, one can revert the server's character set to utf8 for compatibility with older clients. This involves modifying the /etc/my.cnf file and restarting MySQL:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8


[mysqld]
collation-server = utf8_unicode_ci
character-set-server = utf8
Copy after login

Additional Resources:

  • [MySQL Client Bug](https://bugs.mysql.com/bug.php?id=71606)
  • [Instance's Default Character Set](https://dev.mysql.com/doc/refman/8.0/en/charset-charsets.html#charset-configuration)

The above is the detailed content of Why Does My Symfony 3 App Get a 'PDO::__construct(): Server sent charset (255) unknown to the client' Error When Connecting to MySQL 8?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template