PDO::__construct(): Client received an unsupported charset (255) from the server. Contact the developers for assistance.

Solution: 1

In MySQL 8, the default charset was changed to utf8mb4. Some older clients don’t recognize this charset, so when the server reports it, the client fails to understand and throws an error.

Reference: MySQL Bug Report #71606

(This bug is filed against the MySQL Connector/C++, but the issue affects more than just PHP.)

I resolved the issue by switching to utf8 for compatibility with non-upgraded clients. Here’s what I added to /etc/my.cnf, then restarted mysqld:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

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

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

Solution: 2

The accepted answer worked for me (thanks, Bill!), but I ran into an additional related issue and wanted to share my experience.

After upgrading to MySQL 8.0.11, I had the same charset problem when using PHP’s mysqli_connect() function.

In my MySQL directory (/usr/local/mysql in my case), I created a my.cnf file, added the configuration from the accepted answer, and restarted the MySQL server. However, this led to a new error:

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

To fix this, I added the following line to the [mysqld] section of my.cnf:

default_authentication_plugin = mysql_native_password

So my full my.cnf looked like this:

[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

After restarting MySQL, everything worked correctly.

Additional reference: Laradock Issue #1392