Skip to content

Commit

Permalink
feat: 0526 upated.
Browse files Browse the repository at this point in the history
  • Loading branch information
alterhu2020 committed May 27, 2019
1 parent c7a2686 commit 036c722
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/blog/2019/05-26-what.md
@@ -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使新时区生效
```

0 comments on commit 036c722

Please sign in to comment.