依次执行这两条SQL语句:
注意标点符号要英文标点
show variables like '%time_zone';
set GLOBAL time_zone='+8:00';
或者直接在代码中配置如下:
jdbc:mysql://localhost:3306/infosystem
?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
本文介绍如何通过执行SQL语句或在连接字符串中配置参数来设置MySQL数据库的时区为东八区(+8:00),确保数据的时间戳正确显示。
依次执行这两条SQL语句:
注意标点符号要英文标点
show variables like '%time_zone';
set GLOBAL time_zone='+8:00';
或者直接在代码中配置如下:
jdbc:mysql://localhost:3306/infosystem
?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
297
303
1582
256
224
1218

被折叠的 条评论
为什么被折叠?