The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than one time...

本文描述了在配置MySQLDruidDataSource时遇到的服务器时区错误,作者通过进入MySQL控制台并执行命令来解决serverTimeZone不被识别的问题,指出使用`setglobaltime_zone=+8:00`并刷新权限是有效的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Error: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

1 我的配置

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://localhost:3306/db_cloud?characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimeZone=GMT%2B8
    username: root
    password: root
# serverTimeZone=GMT%2B8 或 serverTimezone=Asia/Shanghai
# 两种均可

尝试了很多方法,删掉serverTimeZone也不行,修改成serverTimezone=Asia/Shanghai也不行,最后下面方法成功,并且两种时区设置不影响。

2 我的解决办法

进入到mysql控制台,输入下面的命令

select now();
show variables like '%time_zone%';
set global time_zone = '+8:00';
flush privileges;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不当菜虚困

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值