You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下mariadb-dump备份含Unicode字符的MariaDB数据库报错求助

Windows下含瑞典字符的MariaDB备份编码问题处理

问题场景

在Windows瑞典语区域环境(系统代码页为win-1252)下,使用mariadb-dump.exe备份MariaDB 10.11中名称含瑞典字符“ö”的数据库dbföretag时,执行以下命令报错:

mariadb-dump.exe --user=root --password=XXX --opt --result-file=backup.sql --default-character-set=utf8mb4 --quote-names dbföretag FirstTable SecondTable

报错信息:

mariadb-dump.exe: Error: 'Illegal mix of collations (utf8mb3_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='' when trying to dump tablespaces
mariadb-dump.exe: Got error: 1300: "Invalid utf8mb4 character string: 'dbf\xF6retag'" when selecting the database

问题分析

第二个错误的核心原因是:mariadb-dump.exe将命令行中的“ö”(Unicode码点U+00F6)直接以系统代码页win-1252的单字节\xF6发送给服务器,而非UTF-8编码的0xC3 0xB6,导致服务器无法正确解析UTF-8格式的数据库名称。

尝试过以下操作均无效:

  • 在cmd.exe会话中执行chcp 65001切换代码页
  • 在my.ini的[client]段添加编码配置:
    character_set_connection=utf8mb4
    collation_connection=utf8mb4_bin
    

临时解决方法

在命令行中用Unicode码点为U+00C3和U+00B6的字符ö替代原字符“ö”,修改后的命令可正常执行:

mariadb-dump.exe --user=root --password=XXX --opt --result-file=backup.sql --default-character-set=utf8mb4 --quote-names dbföretag FirstTable SecondTable

官方结论与后续计划

已提交相关Bug,官方答复:新版本Windows(如Server 2022)可正常运行该备份命令,Windows Server 2019即将退出主流支持,不会针对该版本修复此问题。目前计划升级至Windows Server 2022,过渡期间使用上述临时方案。

内容的提问来源于stack exchange,提问作者Kjell Rilbe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 00:40:26