“服务器向客户端发送了未知的字符集(255)"将MySQL字符集设置为utf8 w/o/etc/my.cnf? [英] "Server sent charset (255) unknown to the client" Set MySQL charset to utf8 w/o /etc/my.cnf?

查看:833
本文介绍了“服务器向客户端发送了未知的字符集(255)"将MySQL字符集设置为utf8 w/o/etc/my.cnf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从phpMyAdmin连接到MySQL数据库.但是当我输入用户名和密码时,我收到两条错误消息:

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

我正在使用MySQL 8.0.11和phpMyAdmin 4.8.2

I'm using MySQL 8.0.11 and phpMyAdmin 4.8.2

我找到了类似问题的答案: PDO :: __ construct():服务器向客户端发送了未知的字符集(255).请向开发者报告

I found this answer for a similar problem: PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers

这是重要的部分:"MySQL 8将默认字符集更改为utfmb4.但是某些客户端不知道此字符集.因此,当服务器向客户端报告其默认字符集时,客户端不知道该字符集是什么.服务器的意思是,它将引发此错误."

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."

给出的解决方案是通过在/etc/my.cnf中添加几行,并将默认字符集更改回utf8,然后重新启动mysqld.

The solution given is to change the default charset back to utf8 by adding a few lines to /etc/my.cnf and restart mysqld.

我的问题是/etc/my.cnf在我的文件中不存在,因此我无法在其中更改默认字符集.我看过的所有其他地方最终都引用了/my.cnf或引用了较旧的版本.

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.

那么,对于MySQL 8,如何在没有/etc/my.cnf的情况下将默认字符集更改为utf8?

So, how do I change the default charset to utf8 without a /etc/my.cnf for MySQL 8?

推荐答案

要弄清答案:

  1. /etc/文件夹中创建一个名为my.cnf的文件.

  1. Create a file called my.cnf in your /etc/ folder.

现在将以下文本添加到/etc/my.cnf:

Now add the following text to /etc/my.cnf:

[客户]
default-character-set = utf8

[client]
default-character-set=utf8

[mysql]
default-character-set = utf8

[mysql]
default-character-set=utf8

[mysqld]
整理服务器= utf8_unicode_ci
字符集服务器= utf8
default_authentication_plugin = mysql_native_password

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

最后,重新启动mysql,一切应该一切顺利!如果仍然有问题,请尝试将PHP升级到更高版本.

Finally, restart mysql and all should be well! If you still have an issue, try upgrading PHP to a later version.

这篇关于“服务器向客户端发送了未知的字符集(255)"将MySQL字符集设置为utf8 w/o/etc/my.cnf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆