MySQL time zone and set the default encoding

Case description

To install the Windows learning in local MySQL5.7 spring boot, then configure the project, after the boot prompt you need to set the time zone, and found that in the course of garbled, Chinese can not be displayed, the above problem is mainly MySQL5.7 not set time zone and coding.

solution

1, MySQL data source provided in the configuration file url application.properties spring boot in

spring.datasource.url=jdbc:mysql://localhost:3306/yunzhi_spring_boot?characterEncoding=utf-8&serverTimezone=GMT%2B8

Explanation:

characterEncoding coding for the database is provided, using utf-8;

serverTimezone to set the time zone, "GMT% 2B8" that is GMT + 8, Beijing East eight districts;

Are interested can find out the difference between GMT and UTC.

2, if set up in every case, feel good trouble, directly modify the MySQL configuration file my.ini, set two parameters:

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

Then save and restart the MySQL service.

Project MySQL url can be simplified as:

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

 

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

Guess you like

Origin www.cnblogs.com/clubs/p/12562782.html