1 linux时区设置
直接复制时区文件,覆盖/etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2 mysql时区设置
先用now()获取系统时间,验证
mysql> show variables like '%zone%'; +------------------+--------+ | Variable_name | Value | +------------------+--------+ | system_time_zone | UTC | | time_zone | +08:00 | +------------------+--------+ 2 rows in set (0.00 sec)
//
设置时区,更改为东八区
set global time_zone = '+8:00';
//刷新权限
flush privileges;
//退出当前连接,重进验证
3. jdbc driver,serverTimezone属性
jdbc:mysql://192.168.xx.xx:3306/xxxx?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true