Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrec

jdbc连接mysql报错Exception in thread “main” java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’

Exception in thread "main" 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)

出现以上问题是time Zone问题,具体解决步骤如下:

  1. 用root用户登录mysql(-p后边改为你自己的数据库密码,一般为123456或者root)
mysql -u root -p root 
  1. 通过以下命令查询Time Zone,显示如图(SYSTEM为SQL默认美国时间,而我们中国要比他们迟8小时)
show variables like '%time_zone%';

Exception in thread
3. 修改默认时间:

set global time_zone='+8:00';
  1. 设置完重新打卡命令行,进入mysql,查询time,显示如下就完成啦
    Exception in thread

你可能感兴趣的:(mysql)