com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼

起初这样能短暂解决问题,后来发现每次机器重启了就还是有这样的错误,还是要执行SQL,很麻烦:

show variables like '%time_zone%';

select now();

set global time_zone = '+8:00';

flush privileges;

其实这个不是spring boot + mybatis的问题, 其实是为了使MySQL JDBC驱动程序的5.1.33版本与UTC时区配合使用,必须在连接字符串中明确指定serverTimezone。

jdbc:mysql://localhost:3306/testdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

猜你喜欢

转载自www.cnblogs.com/ukzq/p/10280921.html