Skip to content

Instantly share code, notes, and snippets.

@mildcore
Last active April 21, 2022 09:33
Show Gist options
  • Save mildcore/57bac883973717b4fbf081f31b4ddaa6 to your computer and use it in GitHub Desktop.
Save mildcore/57bac883973717b4fbf081f31b4ddaa6 to your computer and use it in GitHub Desktop.
先说解决方式:
Windows TZ环境变量设置:
TZ=CST-8:00
以下为一些心得:
MySQL的system_time_zone读取错误的问题,会导致以下类似命令出现Warning:
show variables like '%time_zone%';
show variables like '%char%';
原因在于variable里有一个system_time_zone,MySQL从OS读取的时候出现了问题。
用show warnings \G可以查看具体内容
解决思路就在于我们可以自己定义TZ, 让MySQL从OS环境变量里成功读取,关于时区概念可参考:
https://gist.github.com/huameicc/0f5a6c56b291d8d0365411d86b90ff66
验证方式,登陆MySQL:
show variables like '%time_zone%';
select now();
set time_zone=SYSTEM;
show variables like '%time_zone%';
select now();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment