MySQL8.0版本连接问题(解决驱动时区报错)

8.0版本把驱动改为com.mysql.cj.jdbc.Driver后如果还报错
运行报错:
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 utili
错误原因:time zone 时区错误
解决方法:
1.在cmd使用root用户登录mysql
2.show variables like '%time_zone%';
system_time_zone是值是SYSTEM(美国时间)
SYSTEM为SQL默认美国时间,而我们中国要比他们迟8小时
3.时区设置为当前系统时区即可,采用+8:00格式:set global time_zone='+8:00';
4.再次查看show variables like '%time_zone%';
5.如果system_time_zone是值是+8:00,可返回重新运行

发布了17 篇原创文章 · 获赞 42 · 访问量 9576

猜你喜欢

转载自blog.csdn.net/jiangjiaoyong/article/details/100532512