I'm trying to connect to a MySQL database from phpMyAdmin. But when I put in username and password I get two error messages saying:
mysqli_real_connect(): Server sent charset (255) unknown to the client. Please, report to the developers
mysqli_real_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers
I'm using MySQL 8.0.11 and phpMyAdmin 4.8.2
I found this answer for a similar problem: PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers
Here is the important part: "MySQL 8 changed the default charset to utfmb4. But some clients don't know this charset. Hence when the server reports its default charset to the client, and the client doesn't know what the server means, it throws this error."
The solution given is to change the default charset back to utf8 by adding a few lines to /etc/my.cnf and restart mysqld.
My problem is that /etc/my.cnf doesn't exist anywhere in my files so I can't change the default charset there. All of the other places I've looked end up referring to /my.cnf or reference older versions.
So, how do I change the default charset to utf8 without a /etc/my.cnf for MySQL 8?
Reinstall MySQL 8 and choose Second Method "Use Legacy Authentication Method(Retain MySQL 5.x compatibility)" of Authentication while installing.
To clarify the answer:
Create a file called
my.cnf
in your/etc/
folder.Now add the following text to
/etc/my.cnf
:[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
Finally, restart mysql and all should be well! If you still have an issue, try upgrading PHP to a later version.