python config_error ai_generated true

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1298, 'Unknown or incorrect time zone: 'UTC'')

ID: python/mysql-timezone-unsupported

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2024-05-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.4.x active
2.0.x active

Root Cause

MySQL 服务器未加载时区表,导致无法识别 'UTC' 时区。

generic

中文

MySQL 服务器未加载时区表,导致无法识别 'UTC' 时区。

Workarounds

  1. 90% success
    在 MySQL 服务器上执行:mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
  2. 70% success
    在连接字符串中改用 'SYSTEM' 时区,例如:?timezone=SYSTEM

Dead Ends

Common approaches that don't work:

  1. 50% fail

    在连接字符串中移除时区参数,但应用依赖正确时区进行时间计算。

  2. 40% fail

    尝试在 MySQL 中手动创建时区表,但需要 root 权限且过程复杂。