我已经将 php-mysql-apache 设置为在 latin1 上工作,但是在进行备份时我的字符集客户端仍然是 utf8

发布于 2024-09-26 18:26:16 字数 691 浏览 8 评论 0原文

是的,我知道你的想法,但目前我们决定选择 latin1。

这是 mySQL 配置: • mysql>显示类似“character_set_%”的变量;
• +--------------------------+--------+
•|变量名 |价值 |
• +--------------------------+--------+
•|字符集客户端 |拉丁语1 |
•|字符集连接 |拉丁语1 |
•|字符集数据库 |拉丁语1 |
•|字符集结果 |拉丁语1 |
•|字符集服务器 |拉丁语1 |
•|字符集系统 | utf8 |> >这是不可能更改的,因为它是默认的系统参数。

对于 php,我们在 php.ini 中使用以下命令:
mssql.charset = "ISO-8859-1"

对于 apache 通常:
AddDefaultCharset ISO-8859-1

每次我们进行备份时,我们都会将以下内容添加到每个表中:
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!40101 SET character_set_client = utf8 */;

为什么apache/php和mysql之间的连接character_set_client仍然是utf8?

Yes, I know what you think, but for the moment we decided to go for latin1.

This is the mySQL config:
• mysql> SHOW VARIABLES LIKE 'character_set_%';
• +--------------------------+--------+
• | Variable_name | Value |
• +--------------------------+--------+
• | character_set_client | latin1 |
• | character_set_connection | latin1 |
• | character_set_database | latin1 |
• | character_set_results | latin1 |
• | character_set_server | latin1 |
• | character_set_system | utf8 |> This is impossible to change since it is a default system parameter.

For php we use the following commands at php.ini:
mssql.charset = "ISO-8859-1"

For apache the usual:
AddDefaultCharset ISO-8859-1

With all this everytime we do back up we get the following added to each table:
/*!40101 SET @saved_cs_client = @@character_set_client /;
/
!40101 SET character_set_client = utf8 */;

Why the character_set_client is still in utf8 for connections between apache/php and mysql?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

思慕 2024-10-03 18:26:16

mysqldump 不会查看您的 php 或 apache 设置。使用 mysqldump 时,您需要添加 --default-character-set 标志。

来自手册

--default-character-set=charset_name

使用 charset_name 作为默认值
字符集。参见第 9.5 节,
“字符集配置”。如果没有
指定字符集,mysqldump
使用utf8,早期版本使用
拉丁语1。

mysqldump doesn't look at your php or apache settings. You'll need to add the --default-character-set flag when using mysqldump.

From the manual:

--default-character-set=charset_name

Use charset_name as the default
character set. See Section 9.5,
“Character Set Configuration”. If no
character set is specified, mysqldump
uses utf8, and earlier versions use
latin1.

坦然微笑 2024-10-03 18:26:16

如果您仔细注意到您在 php.ini 中设置的指令:

mssql.charset = "ISO-8859-1"

指的是 Microsoft SQL Server! 连接,而不是 MySQL Server

杰克曼

if you notice carefully the directive in the php.ini you have set:

mssql.charset = "ISO-8859-1"

refers to Microsoft SQL Server! connections and not to MySQL Server.

jackman

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文