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

生产环境TiDB部分机器连接报错ERROR 1105 (HY000)的原因及解决方法

Hey there, let's break down this ERROR 1105 (HY000): Unknown charset id 255 error you're hitting in TiDB. I've dealt with similar cases before, so here's what's going on and how to fix it:

Possible Causes

  • Client-server charset incompatibility: Charset ID 255 typically maps to MySQL's binary charset, but TiDB has differences in charset negotiation logic with older clients. If your client (like an outdated MySQL CLI, JDBC driver, or ORM framework) sends a charset ID that TiDB doesn't recognize during connection setup, this error pops up.
  • Incorrect charset config in connection string: If you specify a non-existent charset, or have typos in the charset name (e.g., wrong case, invalid abbreviation), TiDB can't resolve it and returns this error code.
  • TiDB version compatibility bug: Some older TiDB versions (like v4.x or earlier) have bugs in reverse charset ID mapping. When a client requests a charset ID with no corresponding name mapping in TiDB, this error gets thrown.

Solutions

1. Fix charset configuration in your connection string

Make sure you're using a charset supported by TiDB (e.g., utf8mb4, utf8, gbk) and avoid binary or incompatible charsets. Examples:

  • Bad CLI command:
    mysql -h tidb-host -P 4000 -u user -p --default-character-set=binary
    
  • Corrected CLI command:
    mysql -h tidb-host -P 4000 -u user -p --default-character-set=utf8mb4
    
  • For Java JDBC connections, check the characterEncoding parameter:
    // Wrong config
    jdbc:mysql://tidb-host:4000/dbname?characterEncoding=binary
    // Correct config
    jdbc:mysql://tidb-host:4000/dbname?characterEncoding=utf8mb4&useUnicode=true
    

2. Upgrade your client tools/drivers

Outdated MySQL clients (v5.6 or earlier) or JDBC drivers (early mysql-connector-java 5.1.x versions) have charset ID mappings that don't align with TiDB. Upgrade to the latest stable versions:

  • MySQL CLI to 8.0.x
  • JDBC driver to 8.0.x (match it with your application's Java version)

3. Verify TiDB server-side charset settings

Log into TiDB and run this command to check global charset configs:

SHOW VARIABLES LIKE 'character_set_%';

Ensure character_set_server and character_set_database are set to supported charsets (we recommend utf8mb4). Adjust them dynamically if needed:

SET GLOBAL character_set_server = 'utf8mb4';
SET GLOBAL collation_server = 'utf8mb4_general_ci';

Note: Dynamic changes will reset after TiDB restarts. To make them permanent, add these settings to your tidb.toml config file.

4. Temporary workaround for older TiDB versions (if you can't upgrade immediately)

If you're stuck on an older TiDB version (like v4.x), force the charset name explicitly right after connecting:

SET NAMES utf8mb4;

Or add the initConnect=SET NAMES utf8mb4 parameter to your JDBC connection string.

内容的提问来源于stack exchange,提问作者Caitin Chen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 06:39:47