🔍1 问题描述
IDEA连接mysql报红:Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually
。
💡2 原因分析
直接翻译:服务器返回无效时区。转到“高级”选项卡并设置“服务器时区”属性。
🚀3 解决方案
-
最快的解决方法:直接在URL写上:
jdbc:mysql://127.0.0.1:3306/数据库名?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
-
修改
my.ini
配置文件(需重启MySQL服务)[mysqld] // 设置默认时区 default-time_zone=’+8:00’
-
直接在命令行设置时区
set global time_zone = '+8:00'; show variables like'%time_zone';