PDO::__construct() Error: Server Charset Unknown to Client
When attempting to establish a MySQL database connection from a Symfony 3 application, you may encounter the following error:
PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
Problem:
This error arises because the MySQL server is transmitting a character set (255), which is unrecognized by the client. The issue stems from a recent change in MySQL 8, where the default character set was modified to utf8mb4. However, certain clients, including the one utilized by PDO, are unaware of this change, resulting in the error.
Solution:
To resolve this issue, you have two options:
[client] default-character-set=utf8 [mysql] default-character-set=utf8 [mysqld] collation-server = utf8_unicode_ci character-set-server = utf8
By enabling the utf8 character set on the server, you can make it compatible with clients that do not support utf8mb4. This will resolve the charset mismatch error and allow you to establish a successful connection to the MySQL database.
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?. For more information, please follow other related articles on the PHP Chinese website!