当前位置:Gxlcms > 数据库问题 > MySQL设置时区和默认编码

MySQL设置时区和默认编码

时间:2021-07-01 10:21:17 帮助过:23人阅读

localhost:3306/yunzhi_spring_boot?characterEncoding=utf-8&serverTimezone=GMT%2B8

解释:

characterEncoding为设置数据库编码,采用utf-8;

serverTimezone为设置时区,“GMT%2B8”即GMT+8,东八区北京时间;

有兴趣可以了解一下GMT和UTC的区别。

2、如果每次都这样设置,感觉好麻烦,直接修改MySQL的配置文件my.ini,设置两个参数:

default-time-zone=+08:00character-set-server=utf8

然后保存,重启MySQL服务。

项目中的MySQL url就可以简化为:

spring.datasource.url=jdbc:mysql://localhost:3306/yunzhi_spring_boot

 

链接:https://mp.weixin.qq.com/s/Fh-gflUMxEOkH1NIfuDc-Q

MySQL设置时区和默认编码

标签:coding   boot   cat   odi   source   启动   了解   简化   没有   

人气教程排行