SpringBoot: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one ti
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2234)
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2258)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
… 71 more
mysql默认服务器时区问题,将数据库连接修改成上述那样,就能解决
serverTimezone=GMT%2B8
&useUnicode=true&characterEncoding=utf8 :指定字符的编码、解码格式。
例如:mysql数据库用的是gbk编码,而项目数据库用的是utf-8编码。这时候如果添加了useUnicode=true&characterEncoding=UTF-8 ,那么作用有如下两个方面:
- 存数据时:
数据库在存放项目数据的时候会先用UTF-8格式将数据解码成字节码,然后再将解码后的字节码重新使用GBK编码存放到数据库中。
2.取数据时:
在从数据库中取数据的时候,数据库会先将数据库中的数据按GBK格式解码成字节码,然后再将解码后的字节码重新按UTF-8格式编码数据,最后再将数据返回给客户端。
- The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone
- 连接数据库:ERROR: The server time zone value '�й�' is unrecognized or represents more than one time zone
- mysql时区问题(The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one ---)
- The server time zone value '?й???????' is unrecognized or represents more than one time zone. You mu
- mysql出现错误:The server time zone value is unrecognized or represents more than one time zone
- The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You mu
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You
- The server time zone value ‘?й???’ is unrecognized or represents more than one time zone
- Mysql错误:The server time zone value is unrecognized or represents more than one time zone
- The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone.
- The server timezone value 'xxx' is unrecognized or represents more than one time
- The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone.
- mysql连接异常:The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zo
- The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You mu
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You
- Mysql错误:The server time zone value is unrecognized or represents more than one time zone
- 巨坑:The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone.
- 数据库连接 The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone.
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You
- The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.