使用JDBC连接数据库时出现错误:
Exception in thread “main” 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 specific time zone value if you want to utilize time zone support.
解决方案1:
直接在url中加入 ?serverTimezone=UTC 即可解决
解决方案2:
修改数据库时区
在cmd命令中进入mysql输入如下命令即可
set global tize_zone = '+8:00'; ##修改mysql全局时区为北京时区,即我们所在的东8区
set time_zone = '+8:00'; ##修改当前会话时区
flush privileges; ##立即生效
关机或重启mysql服务后需要重新设置
解决方案3:
在mysql的配置文件my.ini中加入
default-time_zone = '+8:00'