mysql异常之: The server time zone value ‘?D1ú±ê×?ê±??‘ is unrecognized or represents more than one time
Posted harsh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql异常之: The server time zone value ‘?D1ú±ê×?ê±??‘ is unrecognized or represents more than one time相关的知识,希望对你有一定的参考价值。
mysql异常之: The server time zone value ‘?D1ú±ê×?ê±??‘ is unrecognized or represents more than one time zone
连接数据库时显示:
java.sql.SQLException: The server time zone value ‘?D1ú±ê×?ê±??‘ 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.
这是由于时区问题导致的, 只需要更改mysql的时区即可:
重启mysql, 再次输入: show variables like ‘%time_zone%‘;
如果还是显示time_zone | SYSTEM
可能是由于还没有更新缓存导致的, 再次输入: set time_zone=‘+8:00‘;
1 2 3 | set global time_zone = ‘+ 8 : 00 ‘; ##修改mysql全局时区为北京时间,即我们所在的东 8 区 set time_zone = ‘+ 8 : 00 ‘; ##修改当前会话时区 flush privileges; #立即生效 |
如果显示Query Ok, 0 rows affected, 那么很可能是已经更新时区成功了
如果以上方法还不可以解决问题, 那么尝试在代码中做调整
jdbc:mysql://127.0.0.1:3306/onestep?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8
重启服务和应用即可
以上是关于mysql异常之: The server time zone value ‘?D1ú±ê×?ê±??‘ is unrecognized or represents more than one time的主要内容,如果未能解决你的问题,请参考以下文章
MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???×¼
MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???×¼
com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value异常解决方案
MySql数据库时区异常,java.sql.SQLException: The server time zone value '?й???×¼
Java spring boot 2.0连接mysql异常:The server time zone value 'Öйú±ê
mysql连接异常:The server time zone value '?й???????' is unrecognized or represents more than one