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

MySQL连接器中欧时区无法识别错误求助及排查

Fixing MySQL Connector Time Zone Error: "The server time zone value 'Mitteleuropäische Sommerzeit' is unrecognized"

Let's work through this issue step by step—this is a common pitfall when dealing with MySQL Connector/J and European time zone configurations, and I’ve helped troubleshoot similar problems before.

Why This Error Pops Up

The root causes here are two-fold:

  • The shorthand CEST (Central European Summer Time) is ambiguous to the JDBC driver. It’s a temporary daylight saving time label, not a standardized, region-specific time zone that the driver can reliably map.
  • Critical mistake: Your JDBC URL uses semicolons (;) to separate parameters instead of ampersands (&). JDBC URLs require & as the parameter separator, so your serverTimezone setting might not even be parsed correctly!

Solutions to Resolve the Issue

1. Fix the JDBC URL with a Specific Time Zone & Correct Syntax

Replace the vague CEST with a standardized Olson time zone identifier (like Europe/Berlin) and fix the parameter separators. Here’s the corrected URL:

URL="jdbc:mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode=false&serverTimezone=Europe/Berlin&useSSL=false"

Olson time zones (e.g., Europe/Paris, Europe/Vienna) are region-specific and include rules for daylight saving transitions, eliminating ambiguity for the driver.

2. Set MySQL Server’s Default Time Zone

If you’d rather not configure the time zone in the JDBC URL, you can set it directly on the MySQL server:

  • Open your MySQL configuration file (my.cnf on Linux, my.ini on Windows).
  • Add or update the default-time-zone parameter under the [mysqld] section:
    [mysqld]
    default-time-zone = 'Europe/Berlin'
    
  • Restart the MySQL service to apply the change.
    This ensures all database connections use the correct time zone by default, so you can optionally remove the serverTimezone parameter from your JDBC URL.

3. Adjust Driver Version & Parameter Compatibility

Since you switched to Connector/J 5.1.39, keep these notes in mind:

  • The useLegacyDatetimeCode=false parameter is primarily relevant for 8.x drivers. For 5.x versions, this defaults to true, so removing it might resolve unexpected behavior.
  • If you decide to upgrade to Connector/J 8.x (recommended for newer MySQL versions), make sure you still use a specific Olson time zone for serverTimezone as outlined in solution 1.

Verify the Fix

After making changes, restart your Tomcat server and test the database connection. The error about an unrecognized time zone should no longer appear.

Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'Mitteleuropäische Sommerzeit' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specific time zone value if you want to utilize time zone support.

内容的提问来源于stack exchange,提问作者Martin Klestil

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:51:00