Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7a2686
commit 036c722
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: 5月26日整理 | ||
--- | ||
|
||
## jackson反序列化myql的datetime类型为LocalDateTime时间错误 | ||
|
||
> 在jackson反序列化mysql中的datetime类型的数据的时候,发现时间总是不一致,发现是mysql的分区和当前运行程序的分区不一致导致的 | ||
- 检查mysql的时区: | ||
|
||
```bash | ||
show variables like "%time_zone%"; | ||
``` | ||
+------------------+--------+ | ||
| Variable_name | Value | | ||
+------------------+--------+ | ||
| system_time_zone | CST | | ||
| time_zone | SYSTEM | | ||
+------------------+--------+ | ||
2 rows in set (0.00 sec) | ||
#time_zone说明mysql使用system的时区,system_time_zone说明system使用CST时区 | ||
|
||
|
||
- 修改mysql的时区: | ||
|
||
```bash | ||
第一种方法 | ||
> set global time_zone = '+08:00'; ##修改mysql全局时区为北京时间,即我们所在的东8区 | ||
> set time_zone = '+08:00'; ##修改当前会话时区 | ||
> flush privileges; #立即生效 | ||
第二种方法 | ||
# vim /etc/my.cnf ##在[mysqld]区域中加上 | ||
default-time_zone = '+08:00' | ||
# /etc/init.d/mysqld restart ##重启mysql使新时区生效 | ||
``` |