【DataGrip | IDEA 异常处理】Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘

问题描述:

用DataGrip连接本地数据库时,提示无效时区:Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone'

【DataGrip | IDEA 异常处理】Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘

原因:根据提示信息内容到Advanced选项卡看到,DataGrip和IDEA连接设置serverTimezone一项默认为空

【DataGrip | IDEA 异常处理】Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘

解决方法:

方法一:可以到Advanced选项卡中将serverTimezone设置为UTC(全球标准时间)或者Asia/Shanghai(中国标准时间)

【DataGrip | IDEA 异常处理】Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘

方法二:也可以在URL上直接加参数 ?serverTimezone=UTC

【DataGrip | IDEA 异常处理】Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘

连接测试通过。

扩展:对Mysql返回时间有符合本地时间要求的,可以将时区设置为中国所在东八区(Hongkong、Asia/Shanghai或者Asia/Hongkong),跟UTC相差8小时(serverTimezone设置