Mysqli::real_connect(): Server sent charset (255) unknown to the client - PHP and MySQL 8

mariadb and mysql logo, most popular dbms

Below is the PHP error occured when developing PHP apps using upgraded version MySQL 8, before that I used MySQL 5.

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

This PHP error happens after i upgrade MySQL version from 5 to 8, it happens because the utf8 is being replaced by utf8mb4. So if you use this SQL queries, you will see what the default charset is being used by MySQL:

show global variables like 'character_set_server';

In MySQL version 8, it showing something character_set_server | utf8mb4.

So the easiest way to solve this problem is to change it back the way it is before, to change it to utf8. So here’s the query to change it back from utf8mb4 to utf8.

You can change the character set by putting or changing this in your my.ini:



collation-server = utf8_unicode_ci
character-set-server = utf8

Save my.ini and restart MySQL service. My.ini can be located in these one of possible location:
  • %PROGRAMDATA%\MySQL\MySQL Server 5.7\my.ini, 
  • %PROGRAMDATA%\MySQL\MySQL Server 5.7\my.cnf
  • %WINDIR%\my.ini
  • %WINDIR%\my.cnf
  • C:\my.ini, C:\my.cnf
  • INSTALLDIR\my.ini
  • INSTALLDIR\my.cnf
That's it, good luck, I hope it solves your problem.


Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Connect SSH Using PEM Certificate On Windows

Which Better WinZip vs WinRAR? Windows Zip and Unzip Tools

How To Create Spring Boot Project Using Netbeans

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously