MySQL connection time zone issue

Using MySQL to connect to the driver is more than 8.0, you need to add the time zone after Url, GMT% 2B8 represents the Chinese time zone, otherwise a time zone error will be reported

spring:
  # 数据库相关配置
  datasource:
    username: root # 用户名
    password: root # 密码
    #使用 MySQL连接驱动是8.0以上,需要在Url后面加上时区, GMT%2B8代表中国时区,不然报时区错误
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=GMT%2B8
    # 注意: 新版本驱动包,要使用以下类作为驱动类 com.mysql.cj.jdbc.Driver
    driver-class-name: com.mysql.jdbc.Driver

Guess you like

Origin www.cnblogs.com/wbyixx/p/12688954.html