解决IDEA出现连接mysql时时区报错问题,亲测推荐!

it2025-03-01  21

先来看看报错内容与你的是否一样,报错内容:

Error querying database. Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' 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 specifc time zone value if you want to utilize time zone support.

解决方案:

1.在数据库配置的xml文件中的url内容当中,语句最后拼接"?serverTimezone=UTC"

如图所示 此错误主要发生在mysql8.0版本上,需要加入上述语句:

扩展:

UTC :协调世界时,又称世界统一时间、世界标准时间、国际协调时间。由于英文(CUT)和法文(TUC)的缩写不同,作为妥协,简称UTC。中国时间与UTC的时差为+8,也就是UTC+8。GMT%2B8 :中国时间(GMT+8这种方式支持全部时区,通过修改最后的数字实现,不过%2B不能写成+)Asia/Shanghai:上海时间
最新回复(0)