原因:
名为 CST 的时区是一个很混乱的时区,在与 MySQL 协商会话时区时,Java 会误以为是 CST -0500,而非 CST +0800。
1.查看时区
show variables like "%time_zone%";
说明:
名为 CST 的时区是一个很混乱的时区,有四种含义:
美国中部时间 Central Standard Time (USA) UTC-06:00
澳大利亚中部时间 Central Standard Time (Australia) UTC+09:30
中国标准时 China Standard Time UTC+08:00
古巴标准时 Cuba Standard Time UTC-04:00
2.用命令连接数据库 mysql -u用户名 -p
3.执行sql
set global time_zone = '+08:00';
Query OK, 0 rows affected (0.00 sec)
4.执行sql
set time_zone = '+08:00';
Query OK, 0 rows affected (0.00 sec) |