小码问答,有问必答!

MYSQL8,Java连接报错

java.sql.SQLException: The server time zone value ‘???ú±ê×??±??’ is unrecognized or represents more than one time zone.

JavaEE

收藏

1个回答

我要回答

  • author
    牛叔叔 2019-05-13 12:34

    服务器时区值不可识别,应该在MySQL连接字符串后面加上属性:serverTimezone=UTC


    MySQL 8.0不能用老版的com.mysql.jdbc.Driver驱动了,需要换成mysql-connector-java-8.0.11.jar包中的com.mysql.cj.jdbc.Driver新版驱动


    连接串url:

    jdbc:mysql://localhost:3306/mail_server?useSSL=false&serverTimezone=UTC