关于mysql解决报错java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or repre

今天在eclipse运行程序时候时,出现如下报错

java.sql.SQLException: 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 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.imooc.jdbc.demo1.JDBCdemo1.demo1(JDBCdemo1.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)...........

发现这是报的mysql系统时区的错误

解决方法通过mysql命令行改回北京时区(东8区)

先查看mysql时区

输入 select curtime(); 和 show variables like "%time_zone%";

关于mysql解决报错java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or repre

time_zone说明mysql使用system的时区。

接着输入 set global time_zone = '+8:00'; 和 set time_zone = '+8:00'; 以及flush privileges;

然后再次查看时区show variables like "%time_zone%";

关于mysql解决报错java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or repre

再次运行程序就不会报这个错了