问题:
1.查询时,数据库表中的时间字段显示有问题,不是北京时间
2.利用mybatis查询mapper.xml文件时报错:
Caused by: java.sql.SQLException: The server time zone value 'EDT' 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.
解决方法:
1. 通过mysql命令行模式下动态修改
show variables like "%time_zone%";
显示如下:
+
------------------+--------+
| Variable_name | Value |
+
------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+
------------------+--------+
2.依次执行如下命令:即可解决问题
> set global time_zone = '+8:00'; ##修改mysql全局时区为北京时间,即我们所在的东8区
> set time_zone = '+8:00'; ##修改当前会话时区
> flush privileges; #立即生效